mirror of
https://github.com/ksherlock/ample.git
synced 2024-09-27 15:58:52 +00:00
Add a cache for the machine description.
This commit is contained in:
parent
5f8b00f021
commit
760f9e6693
@ -23,6 +23,9 @@ NSString *MamePath(void);
|
||||
NSURL *MameWorkingDirectory(void);
|
||||
NSString *MameWorkingDirectoryPath(void);
|
||||
|
||||
|
||||
NSDictionary *MameMachine(NSString *machine);
|
||||
|
||||
/* NSUserDefaults keys */
|
||||
extern NSString *kUseCustomMame;
|
||||
extern NSString *kMamePath;
|
||||
|
@ -90,6 +90,23 @@ NSString *MameWorkingDirectoryPath(void) {
|
||||
}
|
||||
|
||||
|
||||
NSDictionary *MameMachine(NSString *machine) {
|
||||
static NSMutableDictionary *cache;
|
||||
|
||||
if (!cache) cache = [NSMutableDictionary new];
|
||||
NSDictionary *d;
|
||||
|
||||
if (!machine) return nil;
|
||||
d = [cache objectForKey: machine];
|
||||
if (d) return d;
|
||||
|
||||
NSBundle *bundle = [NSBundle mainBundle];
|
||||
NSURL *url= [bundle URLForResource: machine withExtension: @"plist"];
|
||||
|
||||
d = [NSDictionary dictionaryWithContentsOfURL: url];
|
||||
if (d) [cache setObject: d forKey: machine];
|
||||
return d;
|
||||
}
|
||||
|
||||
NSString *kUseCustomMame = @"UseCustomMame";
|
||||
NSString *kMamePath = @"MamePath";
|
||||
|
Loading…
Reference in New Issue
Block a user