Fixed up some stuff in the Apple code (or at least I think I did)
This commit is contained in:
parent
c0ca361da6
commit
ec2d532435
|
@ -56,25 +56,25 @@ int main(int argc, char **argv)
|
||||||
int cheatCount;
|
int cheatCount;
|
||||||
int section;
|
int section;
|
||||||
|
|
||||||
|
#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))
|
||||||
|
{
|
||||||
|
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)
|
if (chdir(DATADIR) == -1)
|
||||||
printf("Warning: failed to change directory to \"%s\"\n", DATADIR);
|
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__
|
|
||||||
CFBundleRef mainBundle = CFBundleGetMainBundle();
|
|
||||||
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
|
|
||||||
char path[PATH_MAX];
|
|
||||||
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
|
|
||||||
{
|
|
||||||
// error!
|
|
||||||
}
|
|
||||||
CFRelease(resourcesURL);
|
|
||||||
|
|
||||||
chdir(path);
|
|
||||||
printf("Current directory \"%s\"\n", path);
|
|
||||||
#endif
|
#endif
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
engine_init(); // Must do this first!
|
engine_init(); // Must do this first!
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue