diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-17 20:41:31 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2011-12-17 20:41:31 +0000 |
| commit | a603862e8da2d061f728a373acb503fa374b8c6b (patch) | |
| tree | ef5f8956e5b6a2977d7ff9229df4a799bbfd1dd0 | |
| parent | b6f15852f36e8d017a275bc3727c5dcab1846d29 (diff) | |
| download | pcsxr-a603862e8da2d061f728a373acb503fa374b8c6b.tar.gz | |
Multiple plug-in directories support for Mac OS X. It could be better: currently it uses hierarchy with the built-in plug-in path at the bottom and the user plug-in path at the top. I should probably do it by plug-in version.
PlayStation plug-in double-clicked on Mac OS X are now moved to the user directory instead of the App's built-in plug-in directory. the previous method could cause problems if write support wasn't set in PCSXR, such as if it was created from a different user.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@73439 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rw-r--r-- | macosx/PcsxrController.m | 4 | ||||
| -rw-r--r-- | macosx/PcsxrPlugin.h | 1 | ||||
| -rw-r--r-- | macosx/PcsxrPlugin.m | 46 | ||||
| -rw-r--r-- | macosx/PcsxrPluginHandler.m | 7 | ||||
| -rw-r--r-- | macosx/PluginList.m | 30 |
5 files changed, 65 insertions, 23 deletions
diff --git a/macosx/PcsxrController.m b/macosx/PcsxrController.m index 72feab3a..dea933b3 100644 --- a/macosx/PcsxrController.m +++ b/macosx/PcsxrController.m @@ -408,6 +408,10 @@ static NSString *HandleBinCue(NSString *toHandle) url = [supportURL URLByAppendingPathComponent:@"Pcsxr/Patches"]; if (![url checkResourceIsReachableAndReturnError:NULL]) [manager createDirectoryAtPath:[url path] withIntermediateDirectories:YES attributes:nil error:NULL]; + + url = [supportURL URLByAppendingPathComponent:@"Pcsxr/PlugIns"]; + if (![url checkResourceIsReachableAndReturnError:NULL]) + [manager createDirectoryAtPath:[url path] withIntermediateDirectories:YES attributes:nil error:NULL]; saveStatePath = [[[supportURL URLByAppendingPathComponent:@"Pcsxr/Save States"] path] copy]; if (![manager fileExistsAtPath:saveStatePath isDirectory:&dir]) diff --git a/macosx/PcsxrPlugin.h b/macosx/PcsxrPlugin.h index f0721161..c971f87c 100644 --- a/macosx/PcsxrPlugin.h +++ b/macosx/PcsxrPlugin.h @@ -23,6 +23,7 @@ + (NSString *)prefixForType:(int)type; + (NSString *)defaultKeyForType:(int)type; + (char **)configEntriesForType:(int)type; ++ (NSArray *)pluginsPaths; - (id)initWithPath:(NSString *)aPath; diff --git a/macosx/PcsxrPlugin.m b/macosx/PcsxrPlugin.m index 33c589cd..5b3dfbe2 100644 --- a/macosx/PcsxrPlugin.m +++ b/macosx/PcsxrPlugin.m @@ -59,6 +59,31 @@ return nil; } ++ (NSArray *)pluginsPaths +{ + NSURL *supportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *libraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *localSupportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *localLibraryURL = [[NSFileManager defaultManager] URLForDirectory:NSLibraryDirectory inDomain:NSLocalDomainMask appropriateForURL:nil create:YES error:NULL]; + + NSMutableArray *mutArray = [NSMutableArray arrayWithCapacity:5]; + + [mutArray addObject:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)]]; + NSURL *url = [localLibraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [localSupportURL URLByAppendingPathComponent:@"Pcsxr/PlugIns"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [libraryURL URLByAppendingPathComponent:@"Playstation Emulator Plugins"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + url = [supportURL URLByAppendingPathComponent:@"Pcsxr/PlugIns"]; + if ([url checkResourceIsReachableAndReturnError:NULL]) + [mutArray addObject:[url path]]; + return [NSArray arrayWithArray:mutArray]; +} + - (id)initWithPath:(NSString *)aPath { if (!(self = [super init])) { @@ -73,14 +98,21 @@ pluginRef = nil; name = nil; path = [aPath retain]; - NSString *fullPath = [[[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)] stringByAppendingPathComponent:path]; + NSString *goodPath = nil; + for (NSString *plugDir in [PcsxrPlugin pluginsPaths]) + { + NSString *fullPath = [plugDir stringByAppendingPathComponent:path]; + if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) { + goodPath = fullPath; + } - pluginRef = SysLoadLibrary([fullPath fileSystemRepresentation]); - if (pluginRef == nil) { - [self release]; - return nil; } - + pluginRef = SysLoadLibrary([goodPath fileSystemRepresentation]); + if (pluginRef == nil) { + [self release]; + return nil; + } + // TODO: add support for plugins with multiple functionalities??? PSE_getLibType = (PSEgetLibType) SysLoadSym(pluginRef, "PSEgetLibType"); if (SysLibError() != nil) { @@ -120,7 +152,7 @@ } // save the current modification date - NSDictionary *fattrs = [[NSFileManager defaultManager] attributesOfItemAtPath:[fullPath stringByResolvingSymlinksInPath] error:NULL]; + NSDictionary *fattrs = [[NSFileManager defaultManager] attributesOfItemAtPath:[goodPath stringByResolvingSymlinksInPath] error:NULL]; modDate = [[fattrs fileModificationDate] retain]; active = 0; diff --git a/macosx/PcsxrPluginHandler.m b/macosx/PcsxrPluginHandler.m index b2231577..8a978876 100644 --- a/macosx/PcsxrPluginHandler.m +++ b/macosx/PcsxrPluginHandler.m @@ -56,12 +56,15 @@ [pluginName setObjectValue:[[NSURL fileURLWithPath:theFile] lastPathComponent]]; [NSApp runModalForWindow:[self window]]; - + [[self window] orderOut:self]; if (moveOK == YES) { + NSURL *supportURL = [[NSFileManager defaultManager] URLForDirectory:NSApplicationSupportDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:NULL]; + NSURL *url = [supportURL URLByAppendingPathComponent:@"Pcsxr/PlugIns"]; + NSFileWrapper *wrapper = [[NSFileWrapper alloc] initWithPath:theFile]; NSString *dst = [NSString stringWithFormat:@"%@/%@", - [[NSBundle mainBundle] builtInPlugInsPath], + [url path], [wrapper filename]]; if ([wrapper writeToFile:dst atomically:NO updateFilenames:NO]) { [[NSWorkspace sharedWorkspace] noteFileSystemChanged:[[NSBundle mainBundle] builtInPlugInsPath]]; diff --git a/macosx/PluginList.m b/macosx/PluginList.m index ba006a50..866e2469 100644 --- a/macosx/PluginList.m +++ b/macosx/PluginList.m @@ -160,20 +160,22 @@ const static int typeList[5] = {PSE_LT_GPU, PSE_LT_SPU, PSE_LT_CDR, PSE_LT_PAD, } } - // look for new ones in the plugin directory - dir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:Config.PluginsDir length:strlen(Config.PluginsDir)]; - dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:dir]; - - while ((pname = [dirEnum nextObject])) { - if ([[pname pathExtension] isEqualToString:@"psxplugin"] || - [[pname pathExtension] isEqualToString:@"so"]) { - [dirEnum skipDescendents]; /* don't enumerate this - directory */ - - if (![self hasPluginAtPath:pname]) { - PcsxrPlugin *plugin = [[PcsxrPlugin alloc] initWithPath:pname]; - if (plugin != nil) { - [pluginList addObject:plugin]; + for (NSString *plugDir in [PcsxrPlugin pluginsPaths]) + { + // look for new ones in the plugin directory + dirEnum = [[NSFileManager defaultManager] enumeratorAtPath:plugDir]; + + while ((pname = [dirEnum nextObject])) { + if ([[pname pathExtension] isEqualToString:@"psxplugin"] || + [[pname pathExtension] isEqualToString:@"so"]) { + [dirEnum skipDescendents]; /* don't enumerate this + directory */ + + if (![self hasPluginAtPath:pname]) { + PcsxrPlugin *plugin = [[PcsxrPlugin alloc] initWithPath:pname]; + if (plugin != nil) { + [pluginList addObject:plugin]; + } } } } |
