//------------------------------------------------- // 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); }
// 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); }