MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / getExecutablePath

Function getExecutablePath

Source/3rdParty/bx/src/filepath.cpp:201–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199 }
200
201 static bool getExecutablePath(char* _out, uint32_t* _inOutSize)
202 {
203#if BX_PLATFORM_WINDOWS
204 uint32_t len = ::GetModuleFileNameA(NULL, _out, *_inOutSize);
205 bool result = len != 0 && len < *_inOutSize;
206 *_inOutSize = len;
207 return result;
208#elif BX_PLATFORM_LINUX
209 char tmp[64];
210 snprintf(tmp, sizeof(tmp), "/proc/%d/exe", getpid() );
211 ssize_t result = readlink(tmp, _out, *_inOutSize);
212
213 if (-1 < result)
214 {
215 *_inOutSize = uint32_t(result);
216 return true;
217 }
218
219 return false;
220#elif BX_PLATFORM_OSX
221 uint32_t len = *_inOutSize;
222 bool result = _NSGetExecutablePath(_out, &len);
223 return 0 == result;
224#else
225 BX_UNUSED(_out, _inOutSize);
226 return false;
227#endif // BX_PLATFORM_*
228 }
229
230 static bool getHomePath(char* _out, uint32_t* _inOutSize)
231 {

Callers 1

setMethod · 0.85

Calls 3

getpidFunction · 0.85
snprintfFunction · 0.70
readlinkFunction · 0.70

Tested by

no test coverage detected