21 #include "../../SDL_internal.h" 24 #import <Foundation/Foundation.h> 35 FILE* SDL_OpenFPFromBundleOrFallback(
const char *file,
const char *
mode)
41 if(strcmp(
"r", mode) && strcmp(
"rb", mode)) {
42 return fopen(file, mode);
45 NSFileManager* file_manager = [NSFileManager defaultManager];
46 NSString* resource_path = [[NSBundle mainBundle] resourcePath];
48 NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
50 NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component];
51 if([file_manager fileExistsAtPath:full_path_with_file_to_try]) {
52 fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
54 fp = fopen(file, mode);