Fixed up some stuff in the Apple code (or at least I think I did)

This commit is contained in:
Julie Marchant 2019-05-27 00:56:51 -04:00
parent c0ca361da6
commit ec2d532435
1 changed files with 17 additions and 17 deletions

View File

@ -56,25 +56,25 @@ int main(int argc, char **argv)
int cheatCount;
int section;
if (chdir(DATADIR) == -1)
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
#ifdef __APPLE__
// This makes relative paths work in Xcode by changing directory to the Resources folder inside the .app bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
if (CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
// error!
}
CFRelease(resourcesURL);
chdir(path);
printf("Current directory \"%s\"\n", path);
}
else
{
if (chdir(DATADIR) == -1)
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
}
#else
if (chdir(DATADIR) == -1)
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
#endif
// ----------------------------------------------------------------------------
engine_init(); // Must do this first!