X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Ffs%2Fdir.cpp;h=218a7a5cf75e0b8a1a05576bf4d5893423f02ec9;hp=098020328342db2edf93d4b2b425555405ab5f00;hb=f804a61c1c58529e7c98555a921b56bc05059d5e;hpb=31cc8f0c6e874e2417e76eda50af34fd17bcd90c diff --git a/source/fs/dir.cpp b/source/fs/dir.cpp index 0980203..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); @@ -191,7 +193,7 @@ Path path_lookup(const string &name, const vector &paths) Path path_lookup(const string &name) { - const char *path = getenv("PATH"); + string path = getenv("PATH"); vector dirs = split(path, ITEMSEP); return path_lookup(name, vector(dirs.begin(), dirs.end())); }