mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
ios: If a .rafilter file has a single filter it is applied automatically.
This commit is contained in:
parent
b8f0c35833
commit
192f7d56d7
@ -16,23 +16,51 @@
|
||||
unsigned _filterCount;
|
||||
}
|
||||
|
||||
- (id)initWithPath:(NSString*)path
|
||||
+ (RADirectoryFilterList*) directoryFilterListAtPath:(NSString*)path useExpression:(NSRegularExpression**)regex
|
||||
{
|
||||
if (regex)
|
||||
*regex = nil;
|
||||
|
||||
if (path && ra_ios_is_file([path stringByAppendingPathComponent:@".rafilter"]))
|
||||
{
|
||||
config_file_t* configFile = config_file_new([[path stringByAppendingPathComponent:@".rafilter"] UTF8String]);
|
||||
|
||||
unsigned filterCount = 0;
|
||||
char* regexValue= 0;
|
||||
|
||||
if (configFile && config_get_uint(configFile, "filter_count", &filterCount) && filterCount > 1)
|
||||
return [[RADirectoryFilterList alloc] initWithPath:path config:configFile];
|
||||
else if (regex && filterCount == 1 && config_get_string(configFile, "filter_1_regex", ®exValue))
|
||||
*regex = [NSRegularExpression regularExpressionWithPattern:[NSString stringWithUTF8String:regexValue] options:0 error:nil];
|
||||
|
||||
free(regexValue);
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id)initWithPath:(NSString*)path config:(config_file_t*)config
|
||||
{
|
||||
self = [super initWithStyle:UITableViewStylePlain];
|
||||
|
||||
|
||||
_path = path;
|
||||
_filterList = config_file_new([[path stringByAppendingPathComponent:@".rafilter"] UTF8String]);
|
||||
|
||||
_filterList = config;
|
||||
|
||||
if (!_filterList || !config_get_uint(_filterList, "filter_count", &_filterCount) || _filterCount == 0)
|
||||
{
|
||||
[RetroArch_iOS displayErrorMessage:@"No valid filters were found."];
|
||||
}
|
||||
|
||||
|
||||
[self setTitle: [path lastPathComponent]];
|
||||
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithPath:(NSString*)path
|
||||
{
|
||||
return [self initWithPath:path config:config_file_new([[path stringByAppendingPathComponent:@".rafilter"] UTF8String])];
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_filterList)
|
||||
|
@ -41,10 +41,10 @@ static NSString* check_path(NSString* path)
|
||||
{
|
||||
path = check_path(path);
|
||||
|
||||
if (path && ra_ios_is_file([path stringByAppendingPathComponent:@".rafilter"]))
|
||||
return [[RADirectoryFilterList alloc] initWithPath:path];
|
||||
else
|
||||
return [RADirectoryList directoryListWithPath:path filter:nil];
|
||||
NSRegularExpression* expr = nil;
|
||||
RADirectoryFilterList* filterList = [RADirectoryFilterList directoryFilterListAtPath:path useExpression:&expr];
|
||||
|
||||
return filterList ? filterList : [RADirectoryList directoryListWithPath:path filter:expr];
|
||||
}
|
||||
|
||||
+ (id)directoryListWithPath:(NSString*)path filter:(NSRegularExpression*)regex
|
||||
|
@ -6,5 +6,9 @@ extern BOOL ra_ios_is_file(NSString* path);
|
||||
@end
|
||||
|
||||
@interface RADirectoryFilterList : UITableViewController
|
||||
// Check path to see if a directory filter list is needed.
|
||||
// If one is not needed useExpression will be set to a default expression to use.
|
||||
+ (RADirectoryFilterList*) directoryFilterListAtPath:(NSString*)path useExpression:(NSRegularExpression**)regex;
|
||||
|
||||
- (id)initWithPath:(NSString*)path;
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user