mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
ios: File browser cleanup.
This commit is contained in:
parent
7cbfae88c1
commit
73fc504546
@ -6,6 +6,13 @@
|
|||||||
// Copyright (c) 2013 RetroArch. All rights reserved.
|
// Copyright (c) 2013 RetroArch. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
static BOOL is_directory(NSString* path)
|
||||||
|
{
|
||||||
|
BOOL result = NO;
|
||||||
|
[[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&result];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@implementation directory_list
|
@implementation directory_list
|
||||||
{
|
{
|
||||||
NSString* directory;
|
NSString* directory;
|
||||||
@ -23,13 +30,12 @@
|
|||||||
|
|
||||||
list = [list sortedArrayUsingComparator:^(id left, id right)
|
list = [list sortedArrayUsingComparator:^(id left, id right)
|
||||||
{
|
{
|
||||||
BOOL left_is_dir;
|
const BOOL left_is_dir = is_directory((NSString*)left);
|
||||||
BOOL right_is_dir;
|
const BOOL right_is_dir = is_directory((NSString*)right);
|
||||||
|
|
||||||
[[NSFileManager defaultManager] fileExistsAtPath:left isDirectory:&left_is_dir];
|
return (left_is_dir != right_is_dir) ?
|
||||||
[[NSFileManager defaultManager] fileExistsAtPath:right isDirectory:&right_is_dir];
|
(left_is_dir ? -1 : 1) :
|
||||||
|
([left caseInsensitiveCompare:right]);
|
||||||
return (left_is_dir != right_is_dir) ? (left_is_dir < right_is_dir) : ([left caseInsensitiveCompare:right]);
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
self.navigationItem.rightBarButtonItem = [RetroArch_iOS get].settings_button;
|
||||||
@ -41,11 +47,8 @@
|
|||||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
NSString* path = [list objectAtIndex: indexPath.row];
|
NSString* path = [list objectAtIndex: indexPath.row];
|
||||||
BOOL isdir;
|
|
||||||
|
|
||||||
if([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isdir])
|
if(is_directory(path))
|
||||||
{
|
|
||||||
if (isdir)
|
|
||||||
{
|
{
|
||||||
[[RetroArch_iOS get].navigator
|
[[RetroArch_iOS get].navigator
|
||||||
pushViewController:[[directory_list alloc] initWithPath:path]
|
pushViewController:[[directory_list alloc] initWithPath:path]
|
||||||
@ -59,7 +62,6 @@
|
|||||||
ios_load_game([path UTF8String]);
|
ios_load_game([path UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
||||||
{
|
{
|
||||||
@ -68,18 +70,14 @@
|
|||||||
|
|
||||||
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
||||||
{
|
{
|
||||||
|
NSString* path = [list objectAtIndex: indexPath.row];
|
||||||
|
BOOL isdir = is_directory(path);
|
||||||
|
|
||||||
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"path"];
|
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"path"];
|
||||||
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"path"];
|
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"path"];
|
||||||
|
|
||||||
NSString* path = [list objectAtIndex: indexPath.row];
|
|
||||||
BOOL isdir;
|
|
||||||
if([[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isdir])
|
|
||||||
{
|
|
||||||
cell.textLabel.text = [path lastPathComponent];
|
cell.textLabel.text = [path lastPathComponent];
|
||||||
cell.accessoryType = (isdir) ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
|
cell.accessoryType = (isdir) ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone;
|
||||||
cell.imageView.image = (isdir) ? [RetroArch_iOS get].folder_icon : [RetroArch_iOS get].file_icon;
|
cell.imageView.image = (isdir) ? [RetroArch_iOS get].folder_icon : [RetroArch_iOS get].file_icon;
|
||||||
}
|
|
||||||
|
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user