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 /macosx/PcsxrPlugin.m | |
| 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
Diffstat (limited to 'macosx/PcsxrPlugin.m')
| -rw-r--r-- | macosx/PcsxrPlugin.m | 46 |
1 files changed, 39 insertions, 7 deletions
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; |
