SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit 2530370f90cac434fe46301da12f365bc19acb87 parent 1fde385cd7139b6595a8db94aff559a6a682a102 Author: Lior Halphon <LIJI32@gmail.com> Date: Thu, 19 Jan 2023 21:07:28 +0200 Fix opening in place Diffstat:
| M | iOS/GBROMManager.m | 26 | ++++++++++++++++---------- |
| M | iOS/GBViewController.m | 4 | +++- |
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/iOS/GBROMManager.m b/iOS/GBROMManager.m @@ -1,4 +1,5 @@ #import "GBROMManager.h" +#include <copyfile.h> @implementation GBROMManager { @@ -142,20 +143,25 @@ error:nil]; NSString *newROMPath = [romFolder stringByAppendingPathComponent:romFile.lastPathComponent]; - - NSError *error = nil; - + if (keep) { - [[NSFileManager defaultManager] linkItemAtPath:romFile - toPath:newROMPath - error:&error]; + if (copyfile(romFile.fileSystemRepresentation, + newROMPath.fileSystemRepresentation, + NULL, + COPYFILE_CLONE)) { + [[NSFileManager defaultManager] removeItemAtPath:romFolder error:nil]; + return nil; + } } else { - [[NSFileManager defaultManager] moveItemAtPath:romFile - toPath:newROMPath - error:&error]; + if (![[NSFileManager defaultManager] moveItemAtPath:romFile + toPath:newROMPath + error:nil]) { + [[NSFileManager defaultManager] removeItemAtPath:romFolder error:nil]; + return nil; + } + } - NSLog(@"%@", error); return friendlyName; } diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m @@ -498,12 +498,14 @@ static void rumbleCallback(GB_gameboy_t *gb, double amp) [GBROMManager sharedManager].currentROM = potentialROM; } else { + [url startAccessingSecurityScopedResource]; [GBROMManager sharedManager].currentROM = [[GBROMManager sharedManager] importROM:url.path keepOriginal:[options[UIApplicationOpenURLOptionsOpenInPlaceKey] boolValue]]; + [url stopAccessingSecurityScopedResource]; } [self loadROM]; [self start]; - return false; + return [GBROMManager sharedManager].currentROM != nil; } @end
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.