MCPcopy Create free account
hub / github.com/aardappel/lobster / GetMainDirFromExePath

Function GetMainDirFromExePath

dev/src/platform.cpp:175–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175string 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
201int64_t DefaultLoadFile(string_view_nt absfilename, string *dest, int64_t start, int64_t len) {
202 LOG_DEBUG("DefaultLoadFile: ", absfilename);

Callers 2

RunCompiledCodeMainFunction · 0.85
main.cppFile · 0.85

Calls 3

SanitizePathFunction · 0.85
StripTrailingFunction · 0.85
StripFilePartFunction · 0.85

Tested by

no test coverage detected