Fix get_exe_dir on OS X

Except on Windows, this detects procfs before using it instead of trying
to detect the OS.
This commit is contained in:
Quentin Pradet 2015-08-30 07:02:41 +04:00
parent 358ffb7277
commit f71784a05b

View File

@ -644,17 +644,21 @@ std::string get_cwd()
}
std::string get_exe_dir()
{
#ifndef _WIN32
path self_exe("/proc/self/exe");
error_code ec;
path exe = bfs::read_symlink(self_exe, ec);
if (ec) {
return std::string();
}
return exe.parent_path().string();
#ifdef _WIN32
return get_cwd();
#else
return get_cwd();
if (bfs::exists("/proc/")) {
path self_exe("/proc/self/exe");
error_code ec;
path exe = bfs::read_symlink(self_exe, ec);
if (ec) {
return std::string();
}
return exe.parent_path().string();
} else {
return get_cwd();
}
#endif
}