mirror of https://github.com/mgba-emu/mgba.git
OpenEmu: Use error handling outputs
This commit is contained in:
parent
c2340bb44f
commit
d662ba98de
|
@ -93,10 +93,7 @@
|
||||||
|
|
||||||
- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
|
- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
|
||||||
{
|
{
|
||||||
UNUSED(error);
|
|
||||||
|
|
||||||
NSString *batterySavesDirectory = [self batterySavesDirectoryPath];
|
NSString *batterySavesDirectory = [self batterySavesDirectoryPath];
|
||||||
NSLog(batterySavesDirectory);
|
|
||||||
[[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:batterySavesDirectory]
|
[[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:batterySavesDirectory]
|
||||||
withIntermediateDirectories:YES
|
withIntermediateDirectories:YES
|
||||||
attributes:nil
|
attributes:nil
|
||||||
|
@ -107,9 +104,14 @@
|
||||||
context.dirs.save = VDirOpen([batterySavesDirectory UTF8String]);
|
context.dirs.save = VDirOpen([batterySavesDirectory UTF8String]);
|
||||||
|
|
||||||
if (!GBAContextLoadROM(&context, [path UTF8String], true)) {
|
if (!GBAContextLoadROM(&context, [path UTF8String], true)) {
|
||||||
|
*error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadROMError userInfo:nil];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GBAContextStart(&context)) {
|
||||||
|
*error = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotStartCoreError userInfo:nil];
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
GBAContextStart(&context);
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,10 +215,13 @@
|
||||||
|
|
||||||
- (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError
|
- (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError
|
||||||
{
|
{
|
||||||
UNUSED(outError);
|
|
||||||
// TODO VFileFromConstMemory
|
// TODO VFileFromConstMemory
|
||||||
struct VFile* vf = VFileFromMemory((void*) state.bytes, state.length);
|
struct VFile* vf = VFileFromMemory((void*) state.bytes, state.length);
|
||||||
return GBALoadStateNamed(context.gba, vf, 0);
|
if (!GBALoadStateNamed(context.gba, vf, 0)) {
|
||||||
|
*outError = [NSError errorWithDomain:OEGameCoreErrorDomain code:OEGameCoreCouldNotLoadStateError userInfo:nil];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
|
- (void)saveStateToFileAtPath:(NSString *)fileName completionHandler:(void (^)(BOOL, NSError *))block
|
||||||
|
|
Loading…
Reference in New Issue