-#include <cstdlib>
-#include <unistd.h>
#include <dirent.h>
#include <msp/core/application.h>
+#include <msp/core/environ.h>
#include <msp/core/systemerror.h>
#include <msp/strings/regex.h>
#include <msp/strings/utils.h>
{
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))
break;
}
}
+ }
if(exe.empty())
exe = realpath(argv0);
Path path_lookup(const string &name)
{
- const char *path = getenv("PATH");
+ string path = getenv("PATH");
vector<string> dirs = split(path, ITEMSEP);
return path_lookup(name, vector<Path>(dirs.begin(), dirs.end()));
}