mirror of
https://github.com/libretro/RetroArch
synced 2025-01-27 12:35:23 +00:00
(iOS) Clean up custom config file path handling
This commit is contained in:
parent
17a73dc47b
commit
729b49e729
@ -18,18 +18,18 @@
|
||||
@interface RAModuleInfo : NSObject
|
||||
@property (strong) NSString* path;
|
||||
@property config_file_t* data;
|
||||
@property (strong) NSString* configPath;
|
||||
@property (strong) NSString* displayName;
|
||||
@property (strong) NSArray* supportedExtensions;
|
||||
@property bool hasCustomConfig;
|
||||
|
||||
+ (NSArray*)getModules;
|
||||
- (bool)supportsFileAtPath:(NSString*)path;
|
||||
|
||||
- (void)createCustomConfig;
|
||||
- (void)deleteCustomConfig;
|
||||
- (bool)hasCustomConfig;
|
||||
|
||||
+ (NSString*)globalConfigPath;
|
||||
- (NSString*)customConfigPath;
|
||||
@property (strong) NSString* customConfigPath;
|
||||
- (NSString*)configPath;
|
||||
@end
|
||||
|
||||
|
@ -41,6 +41,8 @@ static NSMutableArray* moduleList;
|
||||
RAModuleInfo* newInfo = [RAModuleInfo new];
|
||||
newInfo.path = [NSString stringWithUTF8String:files.gl_pathv[i]];
|
||||
|
||||
NSString* baseName = newInfo.path.lastPathComponent.stringByDeletingPathExtension;
|
||||
|
||||
NSString* infoPath = [newInfo.path stringByReplacingOccurrencesOfString:@"_ios.dylib" withString:@".dylib"];
|
||||
infoPath = [infoPath stringByReplacingOccurrencesOfString:@".dylib" withString:@".info"];
|
||||
|
||||
@ -49,19 +51,7 @@ static NSMutableArray* moduleList;
|
||||
newInfo.displayName = ios_get_value_from_config(newInfo.data, @"display_name", newInfo.path.lastPathComponent.stringByDeletingPathExtension);
|
||||
newInfo.supportedExtensions = [ios_get_value_from_config(newInfo.data, @"supported_extensions", @"") componentsSeparatedByString:@"|"];
|
||||
|
||||
// Get config file
|
||||
NSString* customConfigPath = [newInfo customConfigPath];
|
||||
if (path_file_exists(customConfigPath.UTF8String))
|
||||
{
|
||||
newInfo.hasCustomConfig = true;
|
||||
newInfo.configPath = customConfigPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
newInfo.hasCustomConfig = false;
|
||||
newInfo.configPath = self.globalConfigPath;
|
||||
}
|
||||
|
||||
newInfo.customConfigPath = [NSString stringWithFormat:@"%@/%@.cfg", RetroArch_iOS.get.systemDirectory, baseName];
|
||||
|
||||
[moduleList addObject:newInfo];
|
||||
}
|
||||
@ -90,31 +80,32 @@ static NSMutableArray* moduleList;
|
||||
- (void)createCustomConfig
|
||||
{
|
||||
if (!self.hasCustomConfig)
|
||||
{
|
||||
NSString* target = self.customConfigPath;
|
||||
|
||||
[NSFileManager.defaultManager copyItemAtPath:self.configPath toPath:target error:nil];
|
||||
self.hasCustomConfig = true;
|
||||
}
|
||||
[NSFileManager.defaultManager copyItemAtPath:RAModuleInfo.globalConfigPath toPath:self.customConfigPath error:nil];
|
||||
}
|
||||
|
||||
- (void)deleteCustomConfig
|
||||
{
|
||||
if (self.hasCustomConfig)
|
||||
{
|
||||
[NSFileManager.defaultManager removeItemAtPath:self.customConfigPath error:nil];
|
||||
self.hasCustomConfig = false;
|
||||
}
|
||||
}
|
||||
|
||||
+ (NSString*)globalConfigPath
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@/retroarch.cfg", RetroArch_iOS.get.systemDirectory];
|
||||
static NSString* path;
|
||||
if (!path)
|
||||
path = [NSString stringWithFormat:@"%@/retroarch.cfg", RetroArch_iOS.get.systemDirectory];
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
- (NSString*)customConfigPath
|
||||
- (bool)hasCustomConfig
|
||||
{
|
||||
return [NSString stringWithFormat:@"%@/%@.cfg", RetroArch_iOS.get.systemDirectory, self.path.lastPathComponent.stringByDeletingPathExtension];
|
||||
return path_file_exists(self.customConfigPath.UTF8String);
|
||||
}
|
||||
|
||||
- (NSString*)configPath
|
||||
{
|
||||
return self.hasCustomConfig ? self.customConfigPath : RAModuleInfo.globalConfigPath;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user