Replaced manual NSAutoreleasePool handing with @autorelease

This commit is contained in:
stopiccot 2013-01-06 19:04:53 +03:00
parent e1f76ef0ea
commit 929560081c
11 changed files with 699 additions and 769 deletions

View file

@ -21,30 +21,23 @@ FILE* TestSupportRWops_OpenFPFromReadDir(const char *file, const char *mode)
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))
{
if (strcmp("r", mode) && strcmp("rb", mode)) {
return fopen(file, mode);
}
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
@autoreleasepool {
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* resource_path = [[NSBundle mainBundle] resourcePath];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
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);
}
[autorelease_pool drain];
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;
}
@ -53,16 +46,14 @@ FILE* TestSupportRWops_OpenFPFromWriteDir(const char *file, const char *mode)
{
FILE* fp = NULL;
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
@autoreleasepool {
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
[autorelease_pool drain];
fp = fopen([full_path_with_file_to_try fileSystemRepresentation], mode);
}
return fp;
}
@ -75,15 +66,14 @@ SDL_RWops* TestSupportRWops_OpenRWopsFromWriteDir(const char *file, const char *
{
SDL_RWops* rw = NULL;
NSAutoreleasePool* autorelease_pool = [[NSAutoreleasePool alloc] init];
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
[autorelease_pool drain];
@autoreleasepool {
NSFileManager* file_manager = [NSFileManager defaultManager];
NSString* ns_string_file_component = [file_manager stringWithFileSystemRepresentation:file length:strlen(file)];
NSString* full_path_with_file_to_try = [NSTemporaryDirectory() stringByAppendingPathComponent:ns_string_file_component];
rw = SDL_RWFromFile( [full_path_with_file_to_try fileSystemRepresentation], mode );
}
return rw;
}