bool KITTIReader::ReadTimestampFile(QStringList &ts, Timestamp file, unsigned char cam) const { return ReadTimestampFile(ts, timestampFileName(file, cam)); }
static FileSystemResultCode saveSaveStateToFile(CPU *cpu, MMU *mmu, ProgramState *programState, int saveSlot) { CO_ASSERT(saveSlot >= 0 && saveSlot <= 9); char *romName = programState->loadedROMName; FileSystemResultCode ret = FileSystemResultCode::Unknown; char backupPath[MAX_PATH_LEN]; bool didBackup = false; timestampFileName(romName, "gbes.backup", backupPath); char *saveStateFileName = nullptr; buf_gen_memory_printf(saveStateFileName, "%s_%d.gbes", romName, saveSlot); auto copyFileRes = copyFile(saveStateFileName, backupPath, &programState->fileMemory); switch (copyFileRes) { case FileSystemResultCode::OK: didBackup = true; break; case FileSystemResultCode::NotFound: break; default: return copyFileRes; } FILE *f = fopen(saveStateFileName, "wb"); if (!f) { CO_ERR("Could not save game state. Could not open file."); return FileSystemResultCode::NotFound; } buf_gen_memory_free(saveStateFileName); SerializingState ss; ss.f = f; ss.isWriting = true; ss.version = (SaveStateVersion)((i32)SaveStateVersion::CurrentPlusOne - 1); ret = serialize(&ss.version, &ss); if (ret != FileSystemResultCode::OK) { CO_ERR("Could not save the version to save state!"); goto exit; } ret = serialize(romName, mmu->romNameLen, &ss); if (ret != FileSystemResultCode::OK) { CO_ERR("Could not save game state. Could not save rom name."); goto exit; } ret = serialize(cpu, &ss); if (ret != FileSystemResultCode::OK) { CO_ERR("Could not save game state. Could not write CPU."); goto exit; } ret = serialize(mmu, &ss); if (ret != FileSystemResultCode::OK) { CO_ERR("Could not save game state. Could not write MMU."); goto exit; } ret = FileSystemResultCode::OK; exit: fclose(f); if (ret == FileSystemResultCode::OK && didBackup) { remove(backupPath); } else if (didBackup) { auto copyRes = copyFile(backupPath, saveStateFileName, &programState->fileMemory); if (copyRes == FileSystemResultCode::OK) { remove(backupPath); } else { //TODO: need to communicate the backup location } } return ret; }
bool KITTIReader::ReadTimestampFile(QVector<double> & tstamps, Timestamp file, unsigned char cam) const { return ReadTimestampFile(tstamps, timestampFileName(file, cam)); }