From 51a34c98e7df133317e5de27a62de619f864b98e Mon Sep 17 00:00:00 2001 From: DeaTh-G Date: Wed, 19 Mar 2025 11:08:26 +0100 Subject: [PATCH] Explicitly set working directory to executable directory on boot --- UnleashedRecomp/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/UnleashedRecomp/main.cpp b/UnleashedRecomp/main.cpp index a55c0181..34d9bce4 100644 --- a/UnleashedRecomp/main.cpp +++ b/UnleashedRecomp/main.cpp @@ -180,12 +180,27 @@ void init() #endif } +void SetWorkingDirectoryToExecutable() +{ + std::filesystem::path exePath; + +#ifdef _WIN32 + exePath = std::filesystem::canonical(std::filesystem::path(_pgmptr)); +#else + exePath = std::filesystem::canonical("/proc/self/exe"); +#endif + + std::filesystem::current_path(exePath.parent_path()); +} + int main(int argc, char *argv[]) { #ifdef _WIN32 timeBeginPeriod(1); #endif + SetWorkingDirectoryToExecutable(); + os::process::CheckConsole(); if (!os::registry::Init())