I’m trying to get the current executable’s file path without the executable name at the end.
I’m doing:
uint32_t size = sizeof(path);
if (_NSGetExecutablePath(path, &size) == 0) {
}
else {
printf("buffer too small; need size %u\n", size);
}
char* program_name = dirname(path); // To remove executable name from the path
It works the path output is: /Users/Me/Desktop/TNT/build/Debug/
But when i was going to add some gui by using SDL library, the output path was wrong:
/Users/Me/Desktop/TNT/build/Debug/TNT.app/
It’s not wrong, it’s right.
From http://en.wikipedia.org/wiki/Application_bundle#Mac_OS_X_application_bundles:
TNT.app/ is the working directory (and the top-level directory of the application bundle) on Mac OSX. You can confirm this if you enter a command shell and
cdto the directory.