rmdir(path);
}
-vector<string> list_files(const Path &path)
-{
- return list_filtered(path, string());
-}
-
Path get_sys_conf_dir()
{
const char *argv0 = Application::get_argv0();
throw system_error("rmdir");
}
-vector<string> list_filtered(const Path &path, const string &filter)
+template<typename F>
+vector<string> list_files_internal(const Path &path, const F &filter)
{
- Regex r_filter(filter);
-
vector<string> result;
DIR *dir = opendir(path.str().c_str());
if(!dir)
const char *fn = de->d_name;
if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0)))
continue;
- if(r_filter.match(fn))
+ if(filter(fn))
result.push_back(fn);
}
closedir(dir);
return result;
}
+vector<string> list_files(const Path &path)
+{
+ return list_files_internal(path, [](const char *){ return true; });
+}
+
+vector<string> list_filtered(const Path &path, const string &filter)
+{
+ Regex r_filter(filter);
+ return list_files_internal(path, [&r_filter](const char *fn){ return r_filter.match(fn); });
+}
+
Path getcwd()
{
char buf[1024];
throw system_error("RemoveDirectory");
}
-vector<string> list_filtered(const Path &path, const string &filter)
+template<typename F>
+vector<string> list_files_internal(const Path &path, const F &filter)
{
- Regex r_filter(filter);
-
vector<string> result;
WIN32_FIND_DATA entry;
string pattern = path.str()+"\\*";
const char *fn = entry.cFileName;
if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0)))
continue;
- if(r_filter.match(fn))
+ if(filter(fn))
result.push_back(fn);
}
return result;
}
+vector<string> list_files(const Path &path)
+{
+ return list_files_internal(path, [](const char *){ return true; });
+}
+
+vector<string> list_filtered(const Path &path, const string &filter)
+{
+ Regex r_filter(filter);
+ return list_files_internal(path, [&r_filter](const char *fn){ return r_filter.match(fn); });
+}
+
/* Windows documentation says Get/SetCurrentDirectory use a global buffer and
are not thread safe. */
static Mutex &cwd_mutex()