mirror of
https://github.com/ksherlock/ample.git
synced 2024-06-08 18:29:30 +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);
|
NSURL *MameWorkingDirectory(void);
|
||||||
NSString *MameWorkingDirectoryPath(void);
|
NSString *MameWorkingDirectoryPath(void);
|
||||||
|
|
||||||
|
|
||||||
|
NSDictionary *MameMachine(NSString *machine);
|
||||||
|
|
||||||
/* NSUserDefaults keys */
|
/* NSUserDefaults keys */
|
||||||
extern NSString *kUseCustomMame;
|
extern NSString *kUseCustomMame;
|
||||||
extern NSString *kMamePath;
|
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 *kUseCustomMame = @"UseCustomMame";
|
||||||
NSString *kMamePath = @"MamePath";
|
NSString *kMamePath = @"MamePath";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user