mirror of
https://github.com/libretro/Play-.git
synced 2025-01-10 18:42:53 +00:00
bf293a69b7
Should fix issues where scanning for disc images can take a long time.
68 lines
1.8 KiB
Objective-C
68 lines
1.8 KiB
Objective-C
//
|
|
// ViewOrientation.m
|
|
// Play
|
|
//
|
|
// Created by Lounge Katt on 8/15/15.
|
|
// Copyright (c) 2015 Jean-Philip Desjardins. All rights reserved.
|
|
//
|
|
|
|
#import "CollectionView.h"
|
|
#import "IosUtils.h"
|
|
#import "DiskUtils.h"
|
|
|
|
@implementation CollectionView
|
|
|
|
@synthesize diskImages;
|
|
|
|
static CollectionView *instance = nil;
|
|
|
|
+ (CollectionView *) getInstance
|
|
{
|
|
@synchronized(self)
|
|
{
|
|
if (instance == nil)
|
|
{
|
|
instance = [CollectionView new];
|
|
}
|
|
}
|
|
return instance;
|
|
}
|
|
|
|
- (NSArray *) buildCollection
|
|
{
|
|
NSString* path = [@"~/Documents" stringByExpandingTildeInPath];
|
|
NSFileManager* localFileManager = [[NSFileManager alloc] init];
|
|
|
|
NSDirectoryEnumerator* dirEnum = [localFileManager enumeratorAtPath: path];
|
|
|
|
NSMutableArray* images = [[NSMutableArray alloc] init];
|
|
|
|
NSString* file = nil;
|
|
while(file = [dirEnum nextObject])
|
|
{
|
|
std::string diskId;
|
|
if(
|
|
IosUtils::IsLoadableExecutableFileName(file) ||
|
|
(IosUtils::IsLoadableDiskImageFileName(file) &&
|
|
DiskUtils::TryGetDiskId([[NSString stringWithFormat:@"%@/%@", path, file] UTF8String], &diskId))
|
|
)
|
|
{
|
|
NSMutableDictionary *disk = [[NSMutableDictionary alloc] init];
|
|
[disk setValue:[NSString stringWithUTF8String:diskId.c_str()] forKey:@"serial"];
|
|
[disk setValue:file forKey:@"file"];
|
|
[images addObject: disk];
|
|
NSLog(@"%@: %s", file, diskId.c_str());
|
|
}
|
|
}
|
|
|
|
self.diskImages = [images sortedArrayUsingComparator:^NSComparisonResult(id a, id b) {
|
|
NSString *first = [[a objectForKey:@"file"] lastPathComponent];
|
|
NSString *second = [[b objectForKey:@"file"] lastPathComponent];
|
|
return [first caseInsensitiveCompare:second];
|
|
}];
|
|
|
|
return self.diskImages;
|
|
}
|
|
|
|
@end
|