diff options
| author | Admiral H. Curtiss <pikachu025@gmail.com> | 2024-07-07 23:48:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-07 23:48:09 +0200 |
| commit | b10d62cf66ac770d598b0d208338c43b73a67caa (patch) | |
| tree | ff37b6cf24660e2cca4ebf2e70d2c0f9e7bbeac4 /Source/Core/Common/FileUtil.cpp | |
| parent | 02e1b9414909db1644562b3669967feff203460f (diff) | |
| parent | ae87bf9af5d6a09a380949b47f2d7c484cea7d01 (diff) | |
Merge pull request #12913 from LillyJadeKatrin/retroachievements-allowlist-test
RetroAchievements - Patch Allowlist Unit Test
Diffstat (limited to 'Source/Core/Common/FileUtil.cpp')
| -rw-r--r-- | Source/Core/Common/FileUtil.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Core/Common/FileUtil.cpp b/Source/Core/Common/FileUtil.cpp index 5582018b30..545bfaba44 100644 --- a/Source/Core/Common/FileUtil.cpp +++ b/Source/Core/Common/FileUtil.cpp @@ -60,6 +60,10 @@ #include "jni/AndroidCommon/AndroidCommon.h" #endif +#if defined(__FreeBSD__) +#include <sys/sysctl.h> +#endif + namespace fs = std::filesystem; namespace File @@ -738,6 +742,15 @@ std::string GetExePath() return PathToString(exe_path_absolute); #elif defined(__APPLE__) return GetBundleDirectory(); +#elif defined(__FreeBSD__) + int name[4]{CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + size_t length = 0; + if (sysctl(name, 4, nullptr, &length, nullptr, 0) != 0 || length == 0) + return {}; + std::string dolphin_exe_path(length, '\0'); + if (sysctl(name, 4, dolphin_exe_path.data(), &length, nullptr, 0) != 0) + return {}; + return dolphin_exe_path; #else char dolphin_exe_path[PATH_MAX]; ssize_t len = ::readlink("/proc/self/exe", dolphin_exe_path, sizeof(dolphin_exe_path)); |
