//------------------------------------------------- // compute_status - compute a detailed status // based on the information we have //------------------------------------------------- void compute_status(audit_record record, rom_entry rom, bool found) { // if not found, provide more details if (!found) { // no good dump if (record.expected_hashes().flag(util.hash_collection.FLAG_NO_DUMP)) { record.set_status(audit_record.audit_status.STATUS_NOT_FOUND, audit_record.audit_substatus.SUBSTATUS_NOT_FOUND_NODUMP); } // optional ROM else if (romload_global.ROM_ISOPTIONAL(rom)) { record.set_status(audit_record.audit_status.STATUS_NOT_FOUND, audit_record.audit_substatus.SUBSTATUS_NOT_FOUND_OPTIONAL); } // just plain old not found else { record.set_status(audit_record.audit_status.STATUS_NOT_FOUND, audit_record.audit_substatus.SUBSTATUS_NOT_FOUND); } } // if found, provide more details else { // length mismatch if (record.expected_length() != record.actual_length()) { record.set_status(audit_record.audit_status.STATUS_FOUND_INVALID, audit_record.audit_substatus.SUBSTATUS_FOUND_WRONG_LENGTH); } // found but needs a dump else if (record.expected_hashes().flag(util.hash_collection.FLAG_NO_DUMP)) { record.set_status(audit_record.audit_status.STATUS_GOOD, audit_record.audit_substatus.SUBSTATUS_FOUND_NODUMP); } // incorrect hash else if (record.expected_hashes() != record.actual_hashes()) { record.set_status(audit_record.audit_status.STATUS_FOUND_INVALID, audit_record.audit_substatus.SUBSTATUS_FOUND_BAD_CHECKSUM); } // correct hash but needs a redump else if (record.expected_hashes().flag(util.hash_collection.FLAG_BAD_DUMP)) { record.set_status(audit_record.audit_status.STATUS_GOOD, audit_record.audit_substatus.SUBSTATUS_GOOD_NEEDS_REDUMP); } // just plain old good else { record.set_status(audit_record.audit_status.STATUS_GOOD, audit_record.audit_substatus.SUBSTATUS_GOOD); } } }
// internal helpers //------------------------------------------------- // audit_one_rom - validate a single ROM entry //------------------------------------------------- audit_record audit_one_rom(ListPointer <rom_entry> rom) //(const rom_entry *rom) { // allocate and append a new record audit_record record = m_record_list.emplace_back(new audit_record(rom, audit_record.media_type.MEDIA_ROM)).Value; //audit_record &record = *m_record_list.emplace(m_record_list.end(), *rom, media_type::ROM); // see if we have a CRC and extract it if so UInt32 crc; bool has_crc = record.expected_hashes().crc(out crc); // find the file and checksum it, getting the file length along the way emu_file file = new emu_file(m_enumerator.options().media_path(), osdcore_global.OPEN_FLAG_READ | osdcore_global.OPEN_FLAG_NO_PRELOAD); file.set_restrict_to_mediapath(true); path_iterator path = new path_iterator(m_searchpath); string curpath; while (path.next(out curpath, record.name())) { // open the file if we can osd_file.error filerr; if (has_crc) { filerr = file.open(curpath, crc); } else { filerr = file.open(curpath); } // if it worked, get the actual length and hashes, then stop if (filerr == osd_file.error.NONE) { record.set_actual(file.hashes(m_validation), file.size()); break; } } file.close(); // compute the final status compute_status(record, rom[0], record.actual_length() != 0); return(record); }
//------------------------------------------------- // audit_one_rom - validate a single ROM entry //------------------------------------------------- audit_record audit_one_rom(std.vector <string> searchpath, Pointer <rom_entry> rom) //audit_record &audit_one_rom(const std::vector<std::string> &searchpath, const rom_entry *rom); { // allocate and append a new record audit_record record = m_record_list.emplace_back(new audit_record(rom, media_type.ROM)).Value; //audit_record &record = *m_record_list.emplace(m_record_list.end(), *rom, media_type::ROM); // see if we have a CRC and extract it if so uint32_t crc; bool has_crc = record.expected_hashes().crc(out crc); // find the file and checksum it, getting the file length along the way emu_file file = new emu_file(m_enumerator.options().media_path(), searchpath, OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD); file.set_restrict_to_mediapath(1); // open the file if we can std.error_condition filerr; if (has_crc) { filerr = file.open(record.name(), crc); } else { filerr = file.open(record.name()); } // if it worked, get the actual length and hashes, then stop if (!filerr) { record.set_actual(file.hashes(m_validation), file.size()); } file.close(); // compute the final status compute_status(record, rom.op, record.actual_length() != 0); return(record); }