Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't change working directory to exe location on non-Windows #223

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}