From d663bbeb7c6958388d515c196bc73956b574ffbb Mon Sep 17 00:00:00 2001 From: "SND\\MaddTheSane_cp" Date: Fri, 26 Jul 2013 19:55:10 +0000 Subject: fixing the wrong project being non-arc. Add a convinience function for running blocks on the main thread syncronously. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@86262 e17a0e51-4ae3-4d35-97c3-1a29b211df97 --- .../SDL/src/file/cocoa/SDL_rwopsbundlesupport.m | 52 +++++++++++----------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'macosx/plugins/Common/SDL/src') diff --git a/macosx/plugins/Common/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m b/macosx/plugins/Common/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m index 2f69bc9a..888c0820 100644 --- a/macosx/plugins/Common/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/macosx/plugins/Common/SDL/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -12,31 +12,33 @@ */ FILE* SDL_OpenFPFromBundleOrFallback(const char *file, const char *mode) { - @autoreleasepool { - FILE* fp = NULL; - - // If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. - if(strcmp("r", mode) && strcmp("rb", mode)) - { - return fopen(file, mode); - } - - NSFileManager* file_manager = [NSFileManager defaultManager]; - NSString* resource_path = [[NSBundle mainBundle] resourcePath]; - - NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; - - NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; - if([file_manager fileExistsAtPath:full_path_with_file_to_try]) - { - fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); - } - else - { - fp = fopen(file, mode); - } - - return fp; + FILE* fp = NULL; + + // If the file mode is writable, skip all the bundle stuff because generally the bundle is read-only. + if(strcmp("r", mode) && strcmp("rb", mode)) + { + return fopen(file, mode); } + + NSAutoreleasePool *pool = [NSAutoreleasePool new]; + + NSFileManager* file_manager = [NSFileManager defaultManager]; + NSString* resource_path = [[NSBundle mainBundle] resourcePath]; + + NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)]; + + NSString* full_path_with_file_to_try = [resource_path stringByAppendingPathComponent:ns_string_file_component]; + if([file_manager fileExistsAtPath:full_path_with_file_to_try]) + { + fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode); + } + else + { + fp = fopen(file, mode); + } + + [pool drain]; + + return fp; } #endif -- cgit v1.2.3