OpenEmu: Use error handling outputs

This commit is contained in:
Jeffrey Pfau 2016-01-02 16:39:27 -08:00
parent c2340bb44f
commit d662ba98de
1 changed files with 11 additions and 6 deletions
src/platform/openemu

View File

@ -93,10 +93,7 @@
- (BOOL)loadFileAtPath:(NSString *)path error:(NSError **)error
{
UNUSED(error);
NSString *batterySavesDirectory = [self batterySavesDirectoryPath];
NSLog(batterySavesDirectory);
[[NSFileManager defaultManager] createDirectoryAtURL:[NSURL fileURLWithPath:batterySavesDirectory]
withIntermediateDirectories:YES
attributes:nil
@ -107,9 +104,14 @@
context.dirs.save = VDirOpen([batterySavesDirectory UTF8String]);
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;
}
GBAContextStart(&context);
return YES;
}
@ -213,10 +215,13 @@
- (BOOL)deserializeState:(NSData *)state withError:(NSError **)outError
{
UNUSED(outError);
// TODO VFileFromConstMemory
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