mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +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,12 +16,35 @@
|
|||||||
unsigned _filterCount;
|
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];
|
self = [super initWithStyle:UITableViewStylePlain];
|
||||||
|
|
||||||
_path = path;
|
_path = path;
|
||||||
_filterList = config_file_new([[path stringByAppendingPathComponent:@".rafilter"] UTF8String]);
|
_filterList = config;
|
||||||
|
|
||||||
if (!_filterList || !config_get_uint(_filterList, "filter_count", &_filterCount) || _filterCount == 0)
|
if (!_filterList || !config_get_uint(_filterList, "filter_count", &_filterCount) || _filterCount == 0)
|
||||||
{
|
{
|
||||||
@ -33,6 +56,11 @@
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id)initWithPath:(NSString*)path
|
||||||
|
{
|
||||||
|
return [self initWithPath:path config:config_file_new([[path stringByAppendingPathComponent:@".rafilter"] UTF8String])];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
if (_filterList)
|
if (_filterList)
|
||||||
|
@ -41,10 +41,10 @@ static NSString* check_path(NSString* path)
|
|||||||
{
|
{
|
||||||
path = check_path(path);
|
path = check_path(path);
|
||||||
|
|
||||||
if (path && ra_ios_is_file([path stringByAppendingPathComponent:@".rafilter"]))
|
NSRegularExpression* expr = nil;
|
||||||
return [[RADirectoryFilterList alloc] initWithPath:path];
|
RADirectoryFilterList* filterList = [RADirectoryFilterList directoryFilterListAtPath:path useExpression:&expr];
|
||||||
else
|
|
||||||
return [RADirectoryList directoryListWithPath:path filter:nil];
|
return filterList ? filterList : [RADirectoryList directoryListWithPath:path filter:expr];
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)directoryListWithPath:(NSString*)path filter:(NSRegularExpression*)regex
|
+ (id)directoryListWithPath:(NSString*)path filter:(NSRegularExpression*)regex
|
||||||
|
@ -6,5 +6,9 @@ extern BOOL ra_ios_is_file(NSString* path);
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RADirectoryFilterList : UITableViewController
|
@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;
|
- (id)initWithPath:(NSString*)path;
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user