| 99 | } |
| 100 | |
| 101 | std::string get_executable_directory() { |
| 102 | #ifdef _WIN32 |
| 103 | char buffer[MAX_PATH]; |
| 104 | GetModuleFileNameA(NULL, buffer, MAX_PATH); |
| 105 | std::string exe_path(buffer); |
| 106 | size_t last_slash = exe_path.find_last_of("\\"); |
| 107 | if (last_slash != std::string::npos) { |
| 108 | return exe_path.substr(0, last_slash); |
| 109 | } |
| 110 | return "."; |
| 111 | #else |
| 112 | char buffer[PATH_MAX] = {0}; |
| 113 | ssize_t len = readlink("/proc/self/exe", buffer, sizeof(buffer) - 1); |
| 114 | if (len > 0) { |
| 115 | buffer[len] = '\0'; |
| 116 | std::string exe_path(buffer); |
| 117 | size_t last_slash = exe_path.find_last_of("/"); |
| 118 | if (last_slash != std::string::npos) { |
| 119 | return exe_path.substr(0, last_slash); |
| 120 | } |
| 121 | } |
| 122 | return "."; |
| 123 | #endif |
| 124 | } |
| 125 | |
| 126 | std::string get_user_directory() { |
| 127 | #ifdef _WIN32 |