4 #include <msp/core/systemerror.h>
5 #include <msp/strings/regex.h>
13 void mkdir(const Path &path, int mode)
15 if(::mkdir(path.str().c_str(), mode)==-1)
16 throw system_error("mkdir");
19 void rmdir(const Path &path)
21 if(::rmdir(path.str().c_str())==-1)
22 throw system_error("rmdir");
26 vector<string> list_files_internal(const Path &path, const F &filter)
28 vector<string> result;
29 DIR *dir = opendir(path.str().c_str());
31 throw system_error("opendir");
33 while(dirent *de = readdir(dir))
35 const char *fn = de->d_name;
36 if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0)))
46 vector<string> list_files(const Path &path)
48 return list_files_internal(path, [](const char *){ return true; });
51 vector<string> list_filtered(const Path &path, const string &filter)
53 Regex r_filter(filter);
54 return list_files_internal(path, [&r_filter](const char *fn){ return r_filter.match(fn); });
60 return ::getcwd(buf, sizeof(buf));
63 void chdir(const Path &path)
65 if(::chdir(path.str().c_str())==-1)
66 throw system_error("chdir");