9 #elif defined(__linux__)
10 #include <linux/limits.h>
18 wchar_t buffer[MAX_PATH];
19 if (GetModuleFileName(
nullptr, buffer, MAX_PATH) == 0) {
20 return std::filesystem::path();
22 std::filesystem::path executable_path(buffer);
23 return executable_path.remove_filename();
24 #elif defined(__linux__)
25 char buffer[PATH_MAX + 1];
26 ssize_t length = readlink(
"/proc/self/exe", buffer,
sizeof(buffer));
27 if (length > PATH_MAX) {
28 return std::filesystem::path();
30 std::filesystem::path executable_path(std::string(buffer, length));
31 return executable_path.remove_filename();
33 return std::filesystem::path();