src/filesystem/cocoa/SDL_sysfilesystem.m
changeset 7700 963200277a0b
parent 7674 0cfb5e88fb95
child 7771 4434498bf4b9
     1.1 --- a/src/filesystem/cocoa/SDL_sysfilesystem.m	Sun Aug 25 11:20:14 2013 -0400
     1.2 +++ b/src/filesystem/cocoa/SDL_sysfilesystem.m	Sun Aug 25 11:24:01 2013 -0400
     1.3 @@ -37,8 +37,21 @@
     1.4  SDL_GetBasePath(void)
     1.5  {
     1.6      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     1.7 -    const char *base = [[[NSBundle mainBundle] bundlePath] UTF8String];
     1.8 +    NSBundle *bundle = [NSBundle mainBundle];
     1.9 +    const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String];
    1.10 +    const char *base = NULL;
    1.11      char *retval = NULL;
    1.12 +    if (baseType == NULL) {
    1.13 +        baseType = "resource";
    1.14 +    }
    1.15 +    if (SDL_strcasecmp(baseType, "bundle")==0) {
    1.16 +        base = [[bundle bundlePath] UTF8String];
    1.17 +    } else if (SDL_strcasecmp(baseType, "parent")==0) {
    1.18 +        base = [[[bundle bundlePath] stringByDeletingLastPathComponent] UTF8String];
    1.19 +    } else {
    1.20 +        /* this returns the exedir for non-bundled  and the resourceDir for bundled apps */
    1.21 +        base = [[bundle resourcePath] UTF8String];
    1.22 +    }
    1.23      if (base) {
    1.24          const size_t len = SDL_strlen(base) + 2;
    1.25          retval = (char *) SDL_malloc(len);