| 173 | } |
| 174 | |
| 175 | string GetMainDirFromExePath(string_view argv_0) { |
| 176 | string md = SanitizePath(argv_0); |
| 177 | #ifdef _WIN32 |
| 178 | // Windows can pass just the exe name without a full path, which is useless. |
| 179 | char winfn[MAX_PATH + 1]; |
| 180 | GetModuleFileName(NULL, winfn, MAX_PATH + 1); |
| 181 | md = winfn; |
| 182 | #endif |
| 183 | #ifdef __linux__ |
| 184 | char path[PATH_MAX]; |
| 185 | iint length = readlink("/proc/self/exe", path, sizeof(path)-1); |
| 186 | if (length != -1) { |
| 187 | path[length] = '\0'; |
| 188 | md = string(path); |
| 189 | } |
| 190 | #endif |
| 191 | #ifdef __APPLE__ |
| 192 | char path[PROC_PIDPATHINFO_MAXSIZE]; |
| 193 | if (proc_pidpath(getpid(), path, sizeof(path)) > 0) { |
| 194 | md = string(path); |
| 195 | } |
| 196 | #endif |
| 197 | md = StripTrailing(StripTrailing(StripFilePart(md), "bin/"), "bin\\"); |
| 198 | return md; |
| 199 | } |
| 200 | |
| 201 | int64_t DefaultLoadFile(string_view_nt absfilename, string *dest, int64_t start, int64_t len) { |
| 202 | LOG_DEBUG("DefaultLoadFile: ", absfilename); |
no test coverage detected