Skip to content

Commit

Permalink
Don't change working directory to exe location on non-Windows
Browse files Browse the repository at this point in the history
Signed-off-by: magic_rb <richard@brezak.sk>
  • Loading branch information
MagicRB committed Feb 9, 2025
1 parent d28fb82 commit c080a59
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Source/Server/Entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ int main(int argc, char* argv[])
std::string mode_arg = argc > 1 ? argv[1] : "";
start_as_client_emulator = (mode_arg == "-client_emulator");

// only do this on Windows, on Linux its very common to not have writable
// access to wherever the binary is installed
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
// Switch working directory to the same directory the
// exe is inside of. Prevents wierdness when we start from visual studio etc.
std::filesystem::path exe_directory = std::filesystem::path(argv[0]).parent_path();
std::filesystem::current_path(exe_directory);
#endif

Log(R"--( ____ __ _____ __ )--");
Log(R"--( / __ \____ ______/ /__ / ___/____ __ __/ /____)--");
Expand Down Expand Up @@ -174,4 +178,4 @@ int main(int argc, char* argv[])
}

return 0;
}
}

0 comments on commit c080a59

Please # to comment.