equal
deleted
inserted
replaced
35 |
35 |
36 char * |
36 char * |
37 SDL_GetBasePath(void) |
37 SDL_GetBasePath(void) |
38 { |
38 { |
39 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
39 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
40 const char *base = [[[NSBundle mainBundle] bundlePath] UTF8String]; |
40 NSBundle *bundle = [NSBundle mainBundle]; |
|
41 const char* baseType = [[[bundle infoDictionary] objectForKey:@"SDL_FILESYSTEM_BASE_DIR_TYPE"] UTF8String]; |
|
42 const char *base = NULL; |
41 char *retval = NULL; |
43 char *retval = NULL; |
|
44 if (baseType == NULL) { |
|
45 baseType = "resource"; |
|
46 } |
|
47 if (SDL_strcasecmp(baseType, "bundle")==0) { |
|
48 base = [[bundle bundlePath] UTF8String]; |
|
49 } else if (SDL_strcasecmp(baseType, "parent")==0) { |
|
50 base = [[[bundle bundlePath] stringByDeletingLastPathComponent] UTF8String]; |
|
51 } else { |
|
52 /* this returns the exedir for non-bundled and the resourceDir for bundled apps */ |
|
53 base = [[bundle resourcePath] UTF8String]; |
|
54 } |
42 if (base) { |
55 if (base) { |
43 const size_t len = SDL_strlen(base) + 2; |
56 const size_t len = SDL_strlen(base) + 2; |
44 retval = (char *) SDL_malloc(len); |
57 retval = (char *) SDL_malloc(len); |
45 if (retval == NULL) { |
58 if (retval == NULL) { |
46 SDL_OutOfMemory(); |
59 SDL_OutOfMemory(); |