mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
- App doesn't crash anymore when a file is shared to it.
- A shared file is copied to /Documents/roms.
This commit is contained in:
parent
6846295f09
commit
f8726fccb0
@ -448,6 +448,28 @@ enum
|
|||||||
[self showGameView];
|
[self showGameView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
||||||
|
NSFileManager *manager = [NSFileManager defaultManager];
|
||||||
|
NSError *error;
|
||||||
|
NSString *romPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/RetroArch/roms"];
|
||||||
|
|
||||||
|
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
|
||||||
|
if ([url startAccessingSecurityScopedResource]) {
|
||||||
|
if (![[url path] containsString:NSHomeDirectory()])
|
||||||
|
if (![manager fileExistsAtPath:destination])
|
||||||
|
if (![manager copyItemAtPath:[url path] toPath:destination error:&error])
|
||||||
|
NSLog(@"Error: Copy of file failed %@", error);
|
||||||
|
[url stopAccessingSecurityScopedResource];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
|
||||||
{
|
{
|
||||||
NSString *filename = (NSString*)url.path.lastPathComponent;
|
NSString *filename = (NSString*)url.path.lastPathComponent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user