2 #import <Foundation/Foundation.h>
13 FILE* SDL_OpenFPFromBundleOrFallback(
const char *
file,
const char *
mode)
18 if(strcmp(
"r", mode) && strcmp(
"rb", mode))
20 return fopen(file, mode);
23 NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
26 NSFileManager* file_manager = [NSFileManager defaultManager];
27 NSString* resource_path = [[NSBundle mainBundle] resourcePath];
29 NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
31 NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
32 if([file_manager fileExistsAtPath:full_path_with_file_to_try])
34 fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
38 fp = fopen(file, mode);
41 [autorelease_pool drain];