mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 13:14:04 +00:00
Merge pull request #11412 from Lennard599/IOS_fix_openURL_crash
IOSApp doesn't crash anymore when a file is shared to it
This commit is contained in:
commit
a061540dd1
@ -448,16 +448,20 @@ enum
|
||||
[self showGameView];
|
||||
}
|
||||
|
||||
-(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]);
|
||||
|
||||
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
|
||||
NSFileManager *manager = [NSFileManager defaultManager];
|
||||
NSString *filename = (NSString*)url.path.lastPathComponent;
|
||||
NSError *error = nil;
|
||||
NSString *destination = [self.documentsDirectory stringByAppendingPathComponent:filename];
|
||||
|
||||
// copy file to documents directory if its not already inside of documents directory
|
||||
if ([url startAccessingSecurityScopedResource]) {
|
||||
if (![[url path] containsString: self.documentsDirectory])
|
||||
if (![manager fileExistsAtPath:destination])
|
||||
if (![manager copyItemAtPath:[url path] toPath:destination error:&error])
|
||||
printf("%s\n", [[error description] UTF8String]);
|
||||
[url stopAccessingSecurityScopedResource];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user