From a46431a2360b8a81004b439fba1f1cba9a2b11a5 Mon Sep 17 00:00:00 2001 From: rogerman Date: Fri, 6 Jan 2012 09:52:23 +0000 Subject: [PATCH] Cocoa Port: - Update more old file handling code to use the new methods added from the last commit. --- desmume/src/cocoa/main_window.h | 3 --- desmume/src/cocoa/main_window.mm | 39 ++++---------------------------- desmume/src/cocoa/nds_control.h | 3 +-- 3 files changed, 6 insertions(+), 39 deletions(-) diff --git a/desmume/src/cocoa/main_window.h b/desmume/src/cocoa/main_window.h index fd1df1953..361d67c05 100644 --- a/desmume/src/cocoa/main_window.h +++ b/desmume/src/cocoa/main_window.h @@ -116,7 +116,4 @@ //delegate - (void)windowDidBecomeMain:(NSNotification*)notification; -- (BOOL)saveStateExistsInSlot:(int)slot; -- (NSString*) getSaveSlotFileName:(unsigned int)slotNumber; - @end diff --git a/desmume/src/cocoa/main_window.mm b/desmume/src/cocoa/main_window.mm index aa4e663bf..3a34c2461 100644 --- a/desmume/src/cocoa/main_window.mm +++ b/desmume/src/cocoa/main_window.mm @@ -284,7 +284,7 @@ NSMenuItem *screenshot_to_file_item = nil; int i; for(i = 0; i < MAX_SLOTS; i++) if([saveSlot_item[i] target] == self) - if([self saveStateExistsInSlot:i] == YES) + if([CocoaDSFile saveStateExistsForSlot:loadedRomURL slotNumber:i]) [saveSlot_item[i] setState:NSOnState]; else [saveSlot_item[i] setState:NSOffState]; @@ -480,7 +480,7 @@ NSMenuItem *screenshot_to_file_item = nil; return result; } - NSString *fileName = [self getSaveSlotFileName:slot]; + NSString *fileName = [CocoaDSFile getSaveSlotFileName:loadedRomURL slotNumber:slot]; if (fileName == nil) { return result; @@ -519,7 +519,7 @@ NSMenuItem *screenshot_to_file_item = nil; return result; } - NSString *fileName = [self getSaveSlotFileName:slot]; + NSString *fileName = [CocoaDSFile getSaveSlotFileName:loadedRomURL slotNumber:slot]; if (fileName == nil) { return result; @@ -1257,7 +1257,7 @@ NSMenuItem *screenshot_to_file_item = nil; [saveSlot_item[i] setTarget:self]; [loadSlot_item[i] setTarget:self]; - if([self saveStateExistsInSlot:i] == YES) + if ([CocoaDSFile saveStateExistsForSlot:loadedRomURL slotNumber:i]) { [saveSlot_item[i] setState:NSOnState]; } else @@ -1443,7 +1443,7 @@ NSMenuItem *screenshot_to_file_item = nil; else for(i = 0; i < MAX_SLOTS; i++) if(item == loadSlot_item[i]) - if([self saveStateExistsInSlot:i] == NO)return NO; + if (![CocoaDSFile saveStateExistsForSlot:loadedRomURL slotNumber:i]) return NO; if(video_output_view == nil) { @@ -1468,33 +1468,4 @@ NSMenuItem *screenshot_to_file_item = nil; return YES; } -- (BOOL)saveStateExistsInSlot:(int)slot -{ - BOOL exists = false; - - NSString *searchPath = [[CocoaDSFile getURLUserAppSupportByKind:@"Save State"] path]; - NSString *searchFileName = [self getSaveSlotFileName:slot]; - - if (searchPath == nil || searchFileName == nil) - { - return exists; - } - - NSFileManager *fileManager = [[NSFileManager alloc] init]; - NSString *searchFullPath = [searchPath stringByAppendingPathComponent:searchFileName]; - - exists = [fileManager isReadableFileAtPath:searchFullPath]; - - [fileManager release]; - - return exists; -} - -- (NSString*) getSaveSlotFileName:(unsigned int)slotNumber -{ - NSString *fileExtension = [NSString stringWithFormat:@".ds%d", slotNumber]; - - return [[[self romFileName] stringByDeletingPathExtension] stringByAppendingString:fileExtension]; -} - @end diff --git a/desmume/src/cocoa/nds_control.h b/desmume/src/cocoa/nds_control.h index 68399d049..3f4375ee3 100644 --- a/desmume/src/cocoa/nds_control.h +++ b/desmume/src/cocoa/nds_control.h @@ -77,8 +77,6 @@ volatile int frame_skip; volatile int speed_limit; volatile int save_type; - - NSURL *loadedRomURL; bool doesConfigNeedUpdate; NSTimeInterval calcTimeBudget; @@ -96,6 +94,7 @@ @public CocoaDSStateBuffer *dsStateBuffer; + NSURL *loadedRomURL; } //Instanciating, setup, and deconstruction