X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Ffs%2Fdir.cpp;h=218a7a5cf75e0b8a1a05576bf4d5893423f02ec9;hb=f804a61c1c58529e7c98555a921b56bc05059d5e;hp=99de180d20ed026812e7fcb2e371dc843a0c333f;hpb=f24e7b96e76b63c9b9b8a6bce4c7a9db64276ea8;p=libs%2Fcore.git diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index 99de180..218a7a5 100644 --- a/source/fs/dir.cpp +++ b/source/fs/dir.cpp @@ -1,7 +1,6 @@ -#include -#include #include #include +#include #include #include #include @@ -38,7 +37,9 @@ const Path &get_bin_dir(const string &argv0) { Path exe; if(argv0.find(DIRSEP)==string::npos) - if(const char *path = getenv("PATH")) + { + string path = getenv("PATH"); + if(!path.empty()) { for(const string &d: split(path, ITEMSEP)) if(exists(Path(d)/argv0)) @@ -47,6 +48,7 @@ const Path &get_bin_dir(const string &argv0) break; } } + } if(exe.empty()) exe = realpath(argv0); @@ -101,16 +103,16 @@ void rmpath(const Path &path) rmdir(path); } -list list_files(const Path &path) +vector list_files(const Path &path) { return list_filtered(path, string()); } -list list_filtered(const Path &path, const string &filter) +vector list_filtered(const Path &path, const string &filter) { Regex r_filter(filter); - list result; + vector result; DIR *dir = opendir(path.str().c_str()); if(!dir) throw system_error("opendir"); @@ -177,7 +179,7 @@ Path get_sys_lib_dir() return dir; } -Path path_lookup(const string &name, const list &paths) +Path path_lookup(const string &name, const vector &paths) { for(const Path &p: paths) { @@ -191,9 +193,9 @@ Path path_lookup(const string &name, const list &paths) Path path_lookup(const string &name) { - const char *path = getenv("PATH"); - list dirs = split(path, ITEMSEP); - return path_lookup(name, list(dirs.begin(), dirs.end())); + string path = getenv("PATH"); + vector dirs = split(path, ITEMSEP); + return path_lookup(name, vector(dirs.begin(), dirs.end())); } } // namespace FS