diff options
| author | Markus Wick <degasus@users.noreply.github.com> | 2015-11-11 12:16:29 +0100 |
|---|---|---|
| committer | Markus Wick <degasus@users.noreply.github.com> | 2015-11-11 12:16:29 +0100 |
| commit | 8924980b49968604d46655321c49fdd7da20384e (patch) | |
| tree | d3e0aa1021cffe582030d04e30bc2bc578e39c18 /Source/Core/Common/FileUtil.cpp | |
| parent | 22b943d083183f85919e5453819a1aad83ce9c6c (diff) | |
| parent | 3cecbae324d2a7551f91d7936e408086218ec8c3 (diff) | |
Merge pull request #3247 from lutris/master
Enable relocatable linux builds
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
| -rw-r--r-- | Source/Core/Common/FileUtil.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 84961d54ad..585b0c5cc1 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -728,12 +728,12 @@ std::string GetBundleDirectory() } #endif -#ifdef _WIN32 std::string& GetExeDirectory() { static std::string DolphinPath; if (DolphinPath.empty()) { +#ifdef _WIN32 TCHAR Dolphin_exe_Path[2048]; TCHAR Dolphin_exe_Clean_Path[MAX_PATH]; GetModuleFileName(nullptr, Dolphin_exe_Path, 2048); @@ -742,10 +742,20 @@ std::string& GetExeDirectory() else DolphinPath = TStrToUTF8(Dolphin_exe_Path); DolphinPath = DolphinPath.substr(0, DolphinPath.find_last_of('\\')); +#else + char Dolphin_exe_Path[PATH_MAX]; + ssize_t len = ::readlink("/proc/self/exe", Dolphin_exe_Path, sizeof(Dolphin_exe_Path)); + if (len == -1 || len == sizeof(Dolphin_exe_Path)) + { + len = 0; + } + Dolphin_exe_Path[len] = '\0'; + DolphinPath = Dolphin_exe_Path; + DolphinPath = DolphinPath.substr(0, DolphinPath.rfind('/')); +#endif } return DolphinPath; } -#endif std::string GetSysDirectory() { @@ -753,7 +763,7 @@ std::string GetSysDirectory() #if defined (__APPLE__) sysDir = GetBundleDirectory() + DIR_SEP + SYSDATA_DIR; -#elif defined (_WIN32) +#elif defined (_WIN32) || defined (LINUX_LOCAL_DEV) sysDir = GetExeDirectory() + DIR_SEP + SYSDATA_DIR; #else sysDir = SYSDATA_DIR; |
