//------------------------------------------------- // 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); } } }
// getters //const simple_list<audit_record> &records() const { return m_record_list; } // audit operations //------------------------------------------------- // audit_media - audit the media described by the // currently-enumerated driver //------------------------------------------------- public summary audit_media(string validation = AUDIT_VALIDATE_FULL) { // start fresh m_record_list.clear(); // store validation for later m_validation = validation; // temporary hack until romload is update: get the driver path and support it for // all searches string driverpath = m_enumerator.config().root_device().searchpath(); int found = 0; int required = 0; int shared_found = 0; int shared_required = 0; // iterate over devices and regions foreach (device_t device in new device_iterator(m_enumerator.config().root_device())) { // determine the search path for this source and iterate through the regions m_searchpath = device.searchpath(); // now iterate over regions and ROMs within for (ListPointer <rom_entry> region = romload_global.rom_first_region(device); region != null; region = romload_global.rom_next_region(region)) { // temporary hack: add the driver path & region name string combinedpath = device.searchpath() + ";" + driverpath; if (!string.IsNullOrEmpty(device.shortname())) { combinedpath += ";" + device.shortname(); } m_searchpath = combinedpath; for (ListPointer <rom_entry> rom = romload_global.rom_first_file(region); rom != null; rom = romload_global.rom_next_file(rom)) { string name = romload_global.ROM_GETNAME(rom[0]); util.hash_collection hashes = new util.hash_collection(romload_global.ROM_GETHASHDATA(rom[0])); device_t shared_device = find_shared_device(device, name, hashes, romload_global.ROM_GETLENGTH(rom[0])); // count the number of files with hashes if (!hashes.flag(util.hash_collection.FLAG_NO_DUMP) && !romload_global.ROM_ISOPTIONAL(rom[0])) { required++; if (shared_device != null) { shared_required++; } } // audit a file audit_record record = null; if (romload_global.ROMREGION_ISROMDATA(region[0])) { record = audit_one_rom(rom); } // audit a disk else if (romload_global.ROMREGION_ISDISKDATA(region[0])) { record = audit_one_disk(rom); } if (record != null) { // count the number of files that are found. if (record.status() == audit_record.audit_status.STATUS_GOOD || (record.status() == audit_record.audit_status.STATUS_FOUND_INVALID && find_shared_device(device, name, record.actual_hashes(), record.actual_length()) == null)) { found++; if (shared_device != null) { shared_found++; } } record.set_shared_device(shared_device); } } } } // if we only find files that are in the parent & either the set has no unique files or the parent is not found, then assume we don't have the set at all if (found == shared_found && required > 0 && (required != shared_required || shared_found == 0)) { m_record_list.clear(); return(summary.NOTFOUND); } // return a summary string unused = ""; return(summarize(m_enumerator.driver().name, ref unused)); }