I have a OS X application as a .app package which can reside in any arbitrary location in the filesystem. Is there a way to find the current path of the package programmatic
The bundle directory might be a problem with command line tools. So i use the following function which uses the mach-0 linker function to resolve shared libraries.
static char* find_executable_filepath () noexcept
{
char path[1];
uint32_t size = 1;
if (_NSGetExecutablePath(path, &size) == 0) return nullptr;
char* res = (char*)malloc(size+1);
if (_NSGetExecutablePath(res, &size) != 0) return nullptr;
char* r = realpath(res, nullptr);
free(res);
return r;
}