diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-18 23:51:13 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-18 23:51:13 +0000 |
| commit | 52dd8ecce8339768bedfb424f9cb233b57cd55f4 (patch) | |
| tree | 3b2771f36c4fa6a071646da7640370ffcdfe5843 /macosx/PcsxrController.m | |
| parent | 04600f548825368b80c710992f1d88be8788591b (diff) | |
| download | pcsxr-52dd8ecce8339768bedfb424f9cb233b57cd55f4.tar.gz | |
Changed utisCanHandle to supportedUTIs.
reworked application:openFile: to check if a PcsxrFileHandle supports a file then, if it does, uses the specified PcsxrFileHandle.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@73485 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PcsxrController.m')
| -rw-r--r-- | macosx/PcsxrController.m | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index dea933b3..41830c26 100644 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -55,7 +55,7 @@ static NSString *HandleBinCue(NSString *toHandle) [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO]; - [openDlg setAllowedFileTypes:[PcsxrDiscHandler utisCanHandle]]; + [openDlg setAllowedFileTypes:[PcsxrDiscHandler supportedUTIs]]; if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSArray* files = [openDlg URLs]; @@ -135,7 +135,7 @@ static NSString *HandleBinCue(NSString *toHandle) [openDlg setCanChooseFiles:YES]; [openDlg setCanChooseDirectories:NO]; - [openDlg setAllowedFileTypes:[PcsxrDiscHandler utisCanHandle]]; + [openDlg setAllowedFileTypes:[PcsxrDiscHandler supportedUTIs]]; if ([openDlg runModal] == NSFileHandlingPanelOKButton) { NSArray* urls = [openDlg URLs]; @@ -476,22 +476,22 @@ static NSString *HandleBinCue(NSString *toHandle) NSRunAlertPanel(NSLocalizedString(@"Error opening file",nil), [NSString stringWithFormat:NSLocalizedString(@"Unable to open %@: %@", nil), [filename lastPathComponent], [err localizedFailureReason]], nil, nil, nil); return NO; } - NSObject<PcsxrFileHandle> *hand = nil; + NSArray *handlers = [NSArray arrayWithObjects:[PcsxrPluginHandler class], [PcsxrMemCardHandler class], [PcsxrFreezeStateHandler class], [PcsxrDiscHandler class], nil]; BOOL isHandled = NO; - if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.plugin"), (CFStringRef)utiFile)) { - hand = [[PcsxrPluginHandler alloc] init]; - isHandled = [hand handleFile:filename]; - } else if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.memcard"), (CFStringRef)utiFile)) { - hand = [[PcsxrMemCardHandler alloc] init]; - isHandled = [hand handleFile:filename]; - } else if(UTTypeEqual(CFSTR("com.codeplex.pcsxr.freeze"), (CFStringRef)utiFile)) { - hand = [[PcsxrFreezeStateHandler alloc] init]; - isHandled = [hand handleFile:filename]; - } else if(UTTypeEqual(CFSTR("com.alcohol-soft.mdfdisc"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.apple.disk-image-ndif"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("public.iso-image"), (CFStringRef)utiFile) || UTTypeEqual(CFSTR("com.codeplex.pcsxr.cuefile"), (CFStringRef)utiFile)) { - hand = [[PcsxrDiscHandler alloc] init]; - isHandled = [hand handleFile:HandleBinCue(filename)]; + for (Class fileHandler in handlers) { + NSObject<PcsxrFileHandle> *hand = [[fileHandler alloc] init]; + BOOL canHandle = NO; + for (NSString *uti in [fileHandler supportedUTIs]) { + if ([[NSWorkspace sharedWorkspace] type:utiFile conformsToType:uti]) { + canHandle = YES; + } + } + if (canHandle) { + isHandled = [hand handleFile:HandleBinCue(filename)]; + } + [hand release]; + } - if (hand) [hand release]; return isHandled; } |
