Add base bat call for mac os

This commit is contained in:
drmortalwombat 2021-09-28 20:54:35 +02:00
parent 3a7e74938e
commit e2a9cf05ac

View File

@ -70,11 +70,20 @@ int main(int argc, const char** argv)
} }
DWORD length = ::GetModuleFileNameA(NULL, basePath, sizeof(basePath)); DWORD length = ::GetModuleFileNameA(NULL, basePath, sizeof(basePath));
#else
#ifdef __APPLE__
uint32_t length = sizeof(basePath);
if (_NSGetExecutablePath(basePath, &length) != 0) {
// Buffer size is too small.
return false;
}
#else #else
int length = readlink("/proc/self/exe", basePath, sizeof(basePath)); int length = readlink("/proc/self/exe", basePath, sizeof(basePath));
// strcpy(basePath, argv[0]); // strcpy(basePath, argv[0]);
// int length = strlen(basePath); // int length = strlen(basePath);
#endif
#endif #endif
while (length > 0 && basePath[length - 1] != '/' && basePath[length - 1] != '\\') while (length > 0 && basePath[length - 1] != '/' && basePath[length - 1] != '\\')
length--; length--;