Set working directory for OS X

This commit is contained in:
MattTuttle
2014-07-30 14:34:21 -05:00
parent c13fa37dc9
commit eab2cffa2c
2 changed files with 17 additions and 5 deletions

View File

@@ -1,5 +1,9 @@
#include "SDLApplication.h"
#ifdef HX_MACOS
#include <CoreFoundation/CoreFoundation.h>
#endif
namespace lime {
@@ -18,6 +22,18 @@ namespace lime {
SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER);
#ifdef HX_MACOS
// set working directory for OS X
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL (CFBundleGetMainBundle ());
char path[PATH_MAX];
if (CFURLGetFileSystemRepresentation (resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) {
chdir(path);
}
CFRelease(resourcesURL);
#endif
currentUpdate = 0;
lastUpdate = 0;
nextUpdate = 0;
@@ -314,4 +330,4 @@ namespace lime {
}
}
}