diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-08-19 21:04:32 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2014-08-19 21:04:32 +0000 |
| commit | 9d66a1ec68ac6ddfd5b455ae505ae7ea7f939aa5 (patch) | |
| tree | 817f90942199a2b9bb7eec7445b3a47214a4b2f9 /macosx/Source | |
| parent | 7a2bc23c5401fe689bab659b46dd6443f1f8a744 (diff) | |
| download | pcsxr-9d66a1ec68ac6ddfd5b455ae505ae7ea7f939aa5.tar.gz | |
OS X: Move the default folder for the memory cards to within the user's Documents folder.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91262 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/Source')
| -rw-r--r-- | macosx/Source/PcsxrController.m | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/macosx/Source/PcsxrController.m b/macosx/Source/PcsxrController.m index 4bdce477..ba2cb774 100644 --- a/macosx/Source/PcsxrController.m +++ b/macosx/Source/PcsxrController.m @@ -406,6 +406,14 @@ static void PSXDiscAppearedCallback(DADiskRef disk, void *context) - (void)applicationDidFinishLaunching:(NSNotification *)notification { self.skipFiles = nil; + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DidMoveMemoryObjects"]) { + NSAlert *memDidMove = [[NSAlert alloc] init]; + memDidMove.messageText = NSLocalizedString(@"PSX Mem moved Desc", @"Playstation Cards did move"); + memDidMove.informativeText = NSLocalizedString(@"Psx Mem Moved", @"Playstation Cards did move"); + memDidMove.alertStyle = NSInformationalAlertStyle; + [memDidMove runModal]; + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"DidMoveMemoryObjects"]; + } } static void ParseErrorStr(NSString *errStr) @@ -663,7 +671,29 @@ otherblock();\ { NSFileManager *manager = [NSFileManager defaultManager]; - NSURL *memoryURL = [[[manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL] URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"Memory Cards"]; + NSURL *oldMemoryURL = [[[manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL] URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"Memory Cards"]; + NSURL *memoryURL = [[[manager URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL] URLByAppendingPathComponent:@"Pcsxr"] URLByAppendingPathComponent:@"Memory Cards"]; + + if (([[[NSProcessInfo processInfo] arguments] count] > 1 && !wasFinderLaunch) && [oldMemoryURL checkResourceIsReachableAndReturnError:NULL]) { + NSDictionary *mcds = @{@"Mcd1": [defaults URLForKey:@"Mcd1"], + @"Mcd2": [defaults URLForKey:@"Mcd2"]}; + for (NSString *key in mcds) { + NSURL *obj = mcds[key]; + NSString *dirPath = [obj.path stringByStandardizingPath]; + NSString *oldDirPath = [oldMemoryURL.path stringByStandardizingPath]; + if ([dirPath hasPrefix:oldDirPath]) { + NSArray *barePath = [[dirPath stringByReplacingOccurrencesOfString:oldDirPath withString:@""] pathComponents]; + NSMutableArray *newPath = [[memoryURL pathComponents] mutableCopy]; + [newPath addObjectsFromArray:barePath]; + NSURL *replacementPath = [NSURL fileURLWithPathComponents:newPath]; + //if ([manager moveItemAtURL:obj toURL:replacementPath error:NULL]) { + [defaults setURL:replacementPath forKey:key]; + //} + } + } + [manager moveItemAtURL:oldMemoryURL toURL:memoryURL error:NULL]; + [defaults setBool:YES forKey:@"DidMoveMemoryObjects"]; + } str = [[[defaults URLForKey:@"Mcd1"] path] fileSystemRepresentation]; if (str) { @@ -745,11 +775,12 @@ otherblock();\ const char *str; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *appDefaults = @{@"NoDynarec": @YES, - @"AutoDetectVideoType": @YES, - @"UseHLE": @NO, - @"PauseInBackground": @YES, - @"Widescreen": @NO, - @"NetPlay": @NO}; + @"AutoDetectVideoType": @YES, + @"UseHLE": @NO, + @"PauseInBackground": @YES, + @"Widescreen": @NO, + @"NetPlay": @NO, + @"DidMoveMemoryObjects": @NO}; [defaults registerDefaults:appDefaults]; @@ -761,7 +792,7 @@ otherblock();\ @"PluginSIO1": [NSValue valueWithPointer:Config.Sio1]}; prefURLKeys = @{@"Mcd1": [NSValue valueWithPointer:Config.Mcd1], - @"Mcd2": [NSValue valueWithPointer:Config.Mcd2]}; + @"Mcd2": [NSValue valueWithPointer:Config.Mcd2]}; prefByteKeys = @{@"NoXaAudio": [NSValue valueWithPointer:&Config.Xa], @"SioIrqAlways": [NSValue valueWithPointer:&Config.SioIrq], @@ -781,19 +812,19 @@ otherblock();\ NSURL *supportURL = [manager URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; if(supportURL != nil) { - NSURL *PcsxrAppSupport; + NSURL *PcsxrAppSupport = [supportURL URLByAppendingPathComponent:@"Pcsxr"]; + NSURL *pcsxrDocument = [[manager URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL] URLByAppendingPathComponent:@"Pcsxr"]; NSURL *MemCardPath; NSURL *url; BOOL dir; - PcsxrAppSupport = [supportURL URLByAppendingPathComponent:@"Pcsxr"]; // create them if needed url = [PcsxrAppSupport URLByAppendingPathComponent:@"Bios"]; if (![url checkResourceIsReachableAndReturnError:NULL]) [manager createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:NULL]; - MemCardPath = [PcsxrAppSupport URLByAppendingPathComponent:@"Memory Cards"]; + MemCardPath = [pcsxrDocument URLByAppendingPathComponent:@"Memory Cards"]; url = MemCardPath; if (![url checkResourceIsReachableAndReturnError:NULL]) [manager createDirectoryAtURL:url withIntermediateDirectories:YES attributes:nil error:NULL]; |
