mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
(iOS) If a directory named 'RetroArchGames' is located in the documents folder it will be used as the browser root. It can be made into a symlink to change the browser root to any directory.
This commit is contained in:
parent
2c4e863994
commit
8aff61c4e6
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
extern BOOL ra_ios_is_directory(NSString* path);
|
extern BOOL ra_ios_is_directory(NSString* path);
|
||||||
extern BOOL ra_ios_is_file(NSString* path);
|
extern BOOL ra_ios_is_file(NSString* path);
|
||||||
extern NSString* ra_ios_check_path(NSString* path);
|
|
||||||
|
|
||||||
@interface RADirectoryItem : NSObject
|
@interface RADirectoryItem : NSObject
|
||||||
@property (strong) NSString* path;
|
@property (strong) NSString* path;
|
||||||
@ -23,6 +22,7 @@ extern NSString* ra_ios_check_path(NSString* path);
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RADirectoryList : UITableViewController
|
@interface RADirectoryList : UITableViewController
|
||||||
|
+ (id)directoryListAtBrowseRoot;
|
||||||
+ (id)directoryListForPath:(NSString*)path;
|
+ (id)directoryListForPath:(NSString*)path;
|
||||||
- (id)initWithPath:(NSString*)path;
|
- (id)initWithPath:(NSString*)path;
|
||||||
@end
|
@end
|
||||||
|
@ -92,27 +92,22 @@ static NSArray* ra_ios_list_directory(NSString* path)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* ra_ios_check_path(NSString* path)
|
|
||||||
{
|
|
||||||
if (path && ra_ios_is_directory(path))
|
|
||||||
return path;
|
|
||||||
|
|
||||||
// The error message can be ugly if it is a long message, but it should never be displayed during normal operation.
|
|
||||||
if (path)
|
|
||||||
[RetroArch_iOS displayErrorMessage:[NSString stringWithFormat:@"Browsed path is not a directory: %@", path]];
|
|
||||||
|
|
||||||
return [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
|
||||||
}
|
|
||||||
|
|
||||||
@implementation RADirectoryList
|
@implementation RADirectoryList
|
||||||
{
|
{
|
||||||
NSString* _path;
|
|
||||||
NSArray* _list;
|
NSArray* _list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (id)directoryListAtBrowseRoot
|
||||||
|
{
|
||||||
|
NSString* rootPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||||
|
NSString* ragPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/RetroArchGames"];
|
||||||
|
|
||||||
|
return [RADirectoryList directoryListForPath:ra_ios_is_directory(ragPath) ? ragPath : rootPath];
|
||||||
|
}
|
||||||
|
|
||||||
+ (id)directoryListForPath:(NSString*)path
|
+ (id)directoryListForPath:(NSString*)path
|
||||||
{
|
{
|
||||||
path = ra_ios_check_path(path);
|
// NOTE: Don't remove or ignore this abstraction, this function will be expanded when cover art comes back.
|
||||||
return [[RADirectoryList alloc] initWithPath:path];
|
return [[RADirectoryList alloc] initWithPath:path];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,10 +115,16 @@ NSString* ra_ios_check_path(NSString* path)
|
|||||||
{
|
{
|
||||||
self = [super initWithStyle:UITableViewStylePlain];
|
self = [super initWithStyle:UITableViewStylePlain];
|
||||||
|
|
||||||
_path = path;
|
if (!ra_ios_is_directory(path))
|
||||||
_list = ra_ios_list_directory(_path);
|
{
|
||||||
|
[RetroArch_iOS displayErrorMessage:[NSString stringWithFormat:@"Browsed path is not a directory: %@", path]];
|
||||||
[self setTitle: [_path lastPathComponent]];
|
_list = [NSArray array];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setTitle: [path lastPathComponent]];
|
||||||
|
_list = ra_ios_list_directory(path);
|
||||||
|
}
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,6 @@
|
|||||||
|
|
||||||
#define GSEVENT_TYPE_KEYDOWN 10
|
#define GSEVENT_TYPE_KEYDOWN 10
|
||||||
#define GSEVENT_TYPE_KEYUP 11
|
#define GSEVENT_TYPE_KEYUP 11
|
||||||
#define GSEVENT_TYPE_MODS 12
|
|
||||||
#define GSEVENT_MOD_CMD (1 << 16)
|
|
||||||
#define GSEVENT_MOD_SHIFT (1 << 17)
|
|
||||||
#define GSEVENT_MOD_ALT (1 << 19)
|
|
||||||
#define GSEVENT_MOD_CTRL (1 << 20)
|
|
||||||
|
|
||||||
//#define HAVE_DEBUG_FILELOG
|
//#define HAVE_DEBUG_FILELOG
|
||||||
|
|
||||||
@ -156,8 +151,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define kDOCSFOLDER [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]
|
|
||||||
|
|
||||||
// From frontend/frontend_ios.c
|
// From frontend/frontend_ios.c
|
||||||
extern void* rarch_main_ios(void* args);
|
extern void* rarch_main_ios(void* args);
|
||||||
extern void ios_frontend_post_event(void (*fn)(void*), void* userdata);
|
extern void ios_frontend_post_event(void (*fn)(void*), void* userdata);
|
||||||
@ -249,13 +242,15 @@ static void event_reload_config(void* userdata)
|
|||||||
ios_log_init();
|
ios_log_init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
self.system_directory = [NSString stringWithFormat:@"%@/.RetroArch", kDOCSFOLDER];
|
NSString* documentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
|
||||||
self.systemConfigPath = [NSString stringWithFormat:@"%@/.RetroArch/frontend.cfg", kDOCSFOLDER];
|
|
||||||
|
self.system_directory = [NSString stringWithFormat:@"%@/.RetroArch", documentsPath];
|
||||||
|
self.systemConfigPath = [NSString stringWithFormat:@"%@/.RetroArch/frontend.cfg", documentsPath];
|
||||||
mkdir([self.system_directory UTF8String], 0755);
|
mkdir([self.system_directory UTF8String], 0755);
|
||||||
|
|
||||||
// Setup window
|
// Setup window
|
||||||
self.delegate = self;
|
self.delegate = self;
|
||||||
[self pushViewController:[RADirectoryList directoryListForPath:kDOCSFOLDER] animated:YES];
|
[self pushViewController:[RADirectoryList directoryListAtBrowseRoot] animated:YES];
|
||||||
|
|
||||||
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
|
||||||
_window.rootViewController = self;
|
_window.rootViewController = self;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user