Fixed: filesystem::get_exe_dir() returned a wrong directory on Windows
It returned the current directory, not the EXE directory.
This commit is contained in:
parent
97952b0d48
commit
702be57481
1 changed files with 9 additions and 1 deletions
|
@ -675,7 +675,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");
|
||||
|
|
Loading…
Add table
Reference in a new issue