MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / getExecutablePath

Function getExecutablePath

Libraries/Testing/Testing.cpp:430–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

428}
429
430static StringSpan getExecutablePath(StringPath& executablePath)
431{
432#if SC_PLATFORM_WINDOWS
433 if (not TestingWindowsDetail::WindowsPath::getExecutablePath(executablePath))
434 {
435 (void)executablePath.resize(0);
436 return {};
437 }
438 return executablePath.view();
439#elif SC_PLATFORM_APPLE
440 uint32_t size = static_cast<uint32_t>(StringPath::MaxPath);
441 if (_NSGetExecutablePath(executablePath.writableSpan().data(), &size) == 0)
442 {
443 const size_t length = ::strlen(executablePath.writableSpan().data());
444 (void)executablePath.resize(length);
445 return executablePath.view();
446 }
447 return {};
448#else
449 const int pathLength = ::readlink("/proc/self/exe", executablePath.writableSpan().data(), StringPath::MaxPath);
450 if (pathLength > 0)
451 {
452 (void)executablePath.resize(static_cast<size_t>(pathLength));
453 return executablePath.view();
454 }
455 return {};
456#endif
457}
458
459static StringSpan getCurrentWorkingDirectory(StringPath& currentWorkingDirectory)
460{

Callers 7

FileSystemTestMethod · 0.85
createMethod · 0.85
buildHotReloadOptionsFunction · 0.85
TestReportMethod · 0.85
getExecutablePathMethod · 0.85

Calls 4

writableSpanMethod · 0.80
resizeMethod · 0.45
viewMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected