-list<string> list_files(const Path &path)
-{
- list<string> result;
- DIR *dir=opendir(path.str().c_str());
- if(dir)
- {
- while(dirent *de=readdir(dir))
- {
- const char *fn=de->d_name;
- if(fn[0]=='.' && (fn[1]==0 || (fn[1]=='.' && fn[2]==0)))
- continue;
- result.push_back(fn);
- }
- closedir(dir);
- }
-
- return result;
-}
-
-bool exists(const Path &path)
-{
- return access(path.str().c_str(), F_OK)==0;
-}
-
-bool is_dir(const Path &path)
-{
- struct stat st;
- if(stat(path, st)==0)
- return S_ISDIR(st.st_mode);
- return false;
-}
-
-Filename splitext(const string &fn)
-{
- Filename result;
- unsigned dot=fn.rfind('.');
- result.base=fn.substr(0, dot);
- if(dot!=string::npos)
- result.ext=fn.substr(dot);
- return result;
-}
-
-int fnmatch(const string &pat, const Path &fn)
-{
-#ifdef WIN32
- return globcasematch(pat, fn.str());
-#else
- return ::fnmatch(pat.c_str(), fn.str().c_str(), FNM_PATHNAME);
-#endif
-}
-