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

Function GetMainDirFromExePath

lobster/src/platform.cpp:151–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151string GetMainDirFromExePath(const char *argv_0) {
152 string md = SanitizePath(argv_0);
153 #ifdef _WIN32
154 // Windows can pass just the exe name without a full path, which is useless.
155 char winfn[MAX_PATH + 1];
156 GetModuleFileName(NULL, winfn, MAX_PATH + 1);
157 md = winfn;
158 #endif
159 #ifdef __linux__
160 char path[PATH_MAX];
161 ssize_t length = readlink("/proc/self/exe", path, sizeof(path)-1);
162 if (length != -1) {
163 path[length] = '\0';
164 md = string(path);
165 }
166 #endif
167 md = StripTrailing(StripTrailing(StripFilePart(md), "bin/"), "bin\\");
168 return md;
169}
170
171int64_t DefaultLoadFile(string_view absfilename, string *dest, int64_t start, int64_t len) {
172 LOG_INFO("DefaultLoadFile: ", absfilename);

Callers 1

mainFunction · 0.85

Calls 3

SanitizePathFunction · 0.85
StripTrailingFunction · 0.85
StripFilePartFunction · 0.85

Tested by

no test coverage detected