| 77 | |
| 78 | #if !(defined(__APPLE__) && defined(__MACH__)) |
| 79 | fs::path getCurrentExecutablePath() |
| 80 | { |
| 81 | char exePath[PATH_MAX] = { 0 }; |
| 82 | #ifdef __linux__ |
| 83 | auto bytesRead = readlink("/proc/self/exe", exePath, sizeof(exePath)); |
| 84 | if (bytesRead == -1) |
| 85 | { |
| 86 | fprintf(stderr, "failed to read /proc/self/exe"); |
| 87 | } |
| 88 | #elif defined(__FreeBSD__) |
| 89 | const int32_t mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; |
| 90 | auto exeLen = sizeof(exePath); |
| 91 | if (sysctl(mib, 4, exePath, &exeLen, nullptr, 0) == -1) |
| 92 | { |
| 93 | fprintf(stderr, "failed to get process path"); |
| 94 | } |
| 95 | #elif defined(__OpenBSD__) |
| 96 | // There is no way to get the path name of a running executable. |
| 97 | // If you are not using the port or package, you may have to change this line! |
| 98 | strlcpy(exePath, "/usr/local/bin/", sizeof(exePath)); |
| 99 | #else |
| 100 | #error "Platform does not support full path exe retrieval" |
| 101 | #endif // __linux__ |
| 102 | return exePath; |
| 103 | } |
| 104 | |
| 105 | fs::path promptDirectory([[maybe_unused]] const std::string& Title, [[maybe_unused]] void* hwnd) |
| 106 | { |
no test coverage detected