mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
- Deleted deprecated openURL method
- Now using self.documentsDirectory - ROMs are saved to documents directory
This commit is contained in:
parent
f8726fccb0
commit
43245c0d9f
@ -450,39 +450,21 @@ enum
|
|||||||
|
|
||||||
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
||||||
NSFileManager *manager = [NSFileManager defaultManager];
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
NSError *error;
|
NSString *filename = (NSString*)url.path.lastPathComponent;
|
||||||
NSString *romPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/RetroArch/roms"];
|
NSError *error = nil;
|
||||||
|
NSString *destination = [self.documentsDirectory stringByAppendingPathComponent:filename];
|
||||||
if (![manager fileExistsAtPath:romPath])
|
|
||||||
if (![manager createDirectoryAtPath:romPath withIntermediateDirectories:NO attributes:nil error:&error])
|
|
||||||
NSLog(@"Error: Create folder failed %@", error);
|
|
||||||
|
|
||||||
NSString *destination = [[romPath stringByAppendingString:@"/"] stringByAppendingString:(NSString*)url.path.lastPathComponent];
|
|
||||||
|
|
||||||
// copy file to roms directory if its not already in documents directory
|
// copy file to documents directory if its not already inside of documents directory
|
||||||
if ([url startAccessingSecurityScopedResource]) {
|
if ([url startAccessingSecurityScopedResource]) {
|
||||||
if (![[url path] containsString:NSHomeDirectory()])
|
if (![[url path] containsString: self.documentsDirectory])
|
||||||
if (![manager fileExistsAtPath:destination])
|
if (![manager fileExistsAtPath:destination])
|
||||||
if (![manager copyItemAtPath:[url path] toPath:destination error:&error])
|
if (![manager copyItemAtPath:[url path] toPath:destination error:&error])
|
||||||
NSLog(@"Error: Copy of file failed %@", error);
|
printf("%s\n", [[error description] UTF8String]);
|
||||||
[url stopAccessingSecurityScopedResource];
|
[url stopAccessingSecurityScopedResource];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
|
||||||
{
|
|
||||||
NSString *filename = (NSString*)url.path.lastPathComponent;
|
|
||||||
NSError *error = nil;
|
|
||||||
|
|
||||||
[[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:[self.documentsDirectory stringByAppendingPathComponent:filename] error:&error];
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
printf("%s\n", [[error description] UTF8String]);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
|
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
|
||||||
{
|
{
|
||||||
#if TARGET_OS_IOS
|
#if TARGET_OS_IOS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user