Fixed: filesystem::get_exe_dir() returned a wrong directory on Windows

It returned the current directory, not the EXE directory.

(cherry picked from commit 702be57481)
This commit is contained in:
Jyrki Vesterinen 2016-01-20 19:54:45 +02:00 committed by Wedge009
parent 6ca4aff829
commit 4e16a5841d

View file

@ -646,7 +646,15 @@ std::string get_cwd()
std::string get_exe_dir()
{
#ifdef _WIN32
return get_cwd();
wchar_t process_path[MAX_PATH];
SetLastError(ERROR_SUCCESS);
GetModuleFileNameW(NULL, process_path, MAX_PATH);
if (GetLastError() != ERROR_SUCCESS) {
return get_cwd();
}
path exe(process_path);
return exe.parent_path().string();
#else
if (bfs::exists("/proc/")) {
path self_exe("/proc/self/exe");