trunk/src/emu/clifront.c
| r18049 | r18050 | |
| 88 | 88 | { CLICOMMAND_LISTSLOTS ";lslot", "0", OPTION_COMMAND, "list available slots and slot devices" }, |
| 89 | 89 | { CLICOMMAND_LISTMEDIA ";lm", "0", OPTION_COMMAND, "list available media for the system" }, |
| 90 | 90 | { CLICOMMAND_LISTSOFTWARE ";lsoft", "0", OPTION_COMMAND, "list known software for the system" }, |
| 91 | { CLICOMMAND_VERIFYSOFTWARE ";vsoft", "0", OPTION_COMMAND, "verify known software for the system" }, |
| 91 | 92 | { CLICOMMAND_GETSOFTLIST ";glist", "0", OPTION_COMMAND, "retrieve software list by name" }, |
| 92 | 93 | { NULL } |
| 93 | 94 | }; |
| r18049 | r18050 | |
| 1282 | 1283 | |
| 1283 | 1284 | |
| 1284 | 1285 | /*------------------------------------------------- |
| 1286 | verifysoftware - verify roms from the software |
| 1287 | list of the specified driver(s) |
| 1288 | -------------------------------------------------*/ |
| 1289 | void cli_frontend::verifysoftware(const char *gamename) |
| 1290 | { |
| 1291 | int_map list_map; |
| 1292 | |
| 1293 | int correct = 0; |
| 1294 | int incorrect = 0; |
| 1295 | int notfound = 0; |
| 1296 | int matched = 0; |
| 1297 | int nrlists = 0; |
| 1298 | |
| 1299 | // determine which drivers to process; return an error if none found |
| 1300 | driver_enumerator drivlist(m_options, gamename); |
| 1301 | if (drivlist.count() == 0) |
| 1302 | { |
| 1303 | throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename); |
| 1304 | } |
| 1305 | |
| 1306 | media_auditor auditor(drivlist); |
| 1307 | while (drivlist.next()) |
| 1308 | { |
| 1309 | matched++; |
| 1310 | |
| 1311 | software_list_device_iterator iter(drivlist.config().root_device()); |
| 1312 | for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) |
| 1313 | { |
| 1314 | if (swlist->list_type() == SOFTWARE_LIST_ORIGINAL_SYSTEM) |
| 1315 | { |
| 1316 | software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL); |
| 1317 | |
| 1318 | if ( list ) |
| 1319 | { |
| 1320 | /* Verify if we have encountered this list before */ |
| 1321 | if (list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE) |
| 1322 | { |
| 1323 | nrlists++; |
| 1324 | |
| 1325 | // Get the actual software list contents |
| 1326 | software_list_parse( list, NULL, NULL ); |
| 1327 | |
| 1328 | for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) ) |
| 1329 | { |
| 1330 | media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST); |
| 1331 | |
| 1332 | // if not found, count that and leave it at that |
| 1333 | if (summary == media_auditor::NOTFOUND) |
| 1334 | { |
| 1335 | notfound++; |
| 1336 | } |
| 1337 | // else display information about what we discovered |
| 1338 | else if(summary != media_auditor::NONE_NEEDED) |
| 1339 | { |
| 1340 | // output the summary of the audit |
| 1341 | astring summary_string; |
| 1342 | auditor.summarize(swinfo->shortname,&summary_string); |
| 1343 | mame_printf_info("%s", summary_string.cstr()); |
| 1344 | |
| 1345 | // display information about what we discovered |
| 1346 | mame_printf_info("romset %s:%s ", swlist->list_name(), swinfo->shortname); |
| 1347 | |
| 1348 | // switch off of the result |
| 1349 | switch (summary) |
| 1350 | { |
| 1351 | case media_auditor::INCORRECT: |
| 1352 | mame_printf_info("is bad\n"); |
| 1353 | incorrect++; |
| 1354 | break; |
| 1355 | |
| 1356 | case media_auditor::CORRECT: |
| 1357 | mame_printf_info("is good\n"); |
| 1358 | correct++; |
| 1359 | break; |
| 1360 | |
| 1361 | case media_auditor::BEST_AVAILABLE: |
| 1362 | mame_printf_info("is best available\n"); |
| 1363 | correct++; |
| 1364 | break; |
| 1365 | |
| 1366 | default: |
| 1367 | break; |
| 1368 | } |
| 1369 | } |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | software_list_close( list ); |
| 1374 | } |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | // clear out any cached files |
| 1380 | zip_file_cache_clear(); |
| 1381 | |
| 1382 | // return an error if none found |
| 1383 | if (matched == 0) |
| 1384 | throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "No matching games found for '%s'", gamename); |
| 1385 | |
| 1386 | // if we didn't get anything at all, display a generic end message |
| 1387 | if (matched > 0 && correct == 0 && incorrect == 0) |
| 1388 | { |
| 1389 | throw emu_fatalerror(MAMERR_MISSING_FILES, "romset \"%s\" has no software entries defined!\n", gamename); |
| 1390 | } |
| 1391 | // otherwise, print a summary |
| 1392 | else |
| 1393 | { |
| 1394 | if (incorrect > 0) |
| 1395 | throw emu_fatalerror(MAMERR_MISSING_FILES, "%d romsets found in %d software lists, %d were OK.\n", correct + incorrect, nrlists, correct); |
| 1396 | mame_printf_info("%d romsets found in %d software lists, %d romsets were OK.\n", correct, nrlists, correct); |
| 1397 | } |
| 1398 | |
| 1399 | } |
| 1400 | |
| 1401 | /*------------------------------------------------- |
| 1285 | 1402 | getsoftlist - retrieve software list by name |
| 1286 | 1403 | -------------------------------------------------*/ |
| 1287 | 1404 | |
| r18049 | r18050 | |
| 1423 | 1540 | { CLICOMMAND_VERIFYSAMPLES, &cli_frontend::verifysamples }, |
| 1424 | 1541 | { CLICOMMAND_LISTMEDIA, &cli_frontend::listmedia }, |
| 1425 | 1542 | { CLICOMMAND_LISTSOFTWARE, &cli_frontend::listsoftware }, |
| 1543 | { CLICOMMAND_VERIFYSOFTWARE, &cli_frontend::verifysoftware }, |
| 1426 | 1544 | { CLICOMMAND_ROMIDENT, &cli_frontend::romident }, |
| 1427 | 1545 | { CLICOMMAND_GETSOFTLIST, &cli_frontend::getsoftlist }, |
| 1428 | 1546 | }; |
trunk/src/emu/audit.c
| r18049 | r18050 | |
| 207 | 207 | |
| 208 | 208 | |
| 209 | 209 | //------------------------------------------------- |
| 210 | // audit_software |
| 211 | //------------------------------------------------- |
| 212 | media_auditor::summary media_auditor::audit_software(const char *list_name, software_info *swinfo, const char *validation) |
| 213 | { |
| 214 | // start fresh |
| 215 | m_record_list.reset(); |
| 216 | |
| 217 | // store validation for later |
| 218 | m_validation = validation; |
| 219 | |
| 220 | astring combinedpath(swinfo->shortname, ";", list_name, PATH_SEPARATOR, swinfo->shortname); |
| 221 | m_searchpath = combinedpath; |
| 222 | |
| 223 | int found = 0; |
| 224 | int required = 0; |
| 225 | |
| 226 | // now iterate over software parts |
| 227 | for ( software_part *part = software_find_part( swinfo, NULL, NULL ); part != NULL; part = software_part_next( part ) ) |
| 228 | { |
| 229 | // now iterate over regions |
| 230 | for ( const rom_entry *region = part->romdata; region; region = rom_next_region( region ) ) |
| 231 | { |
| 232 | // now iterate over rom definitions |
| 233 | for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom)) |
| 234 | { |
| 235 | hash_collection hashes(ROM_GETHASHDATA(rom)); |
| 236 | |
| 237 | // count the number of files with hashes |
| 238 | if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom)) |
| 239 | { |
| 240 | required++; |
| 241 | } |
| 242 | |
| 243 | // audit a file |
| 244 | audit_record *record = NULL; |
| 245 | if (ROMREGION_ISROMDATA(region)) |
| 246 | { |
| 247 | record = audit_one_rom(rom); |
| 248 | } |
| 249 | // audit a disk |
| 250 | else if (ROMREGION_ISDISKDATA(region)) |
| 251 | { |
| 252 | record = audit_one_disk(rom); |
| 253 | } |
| 254 | |
| 255 | // count the number of files that are found. |
| 256 | if (record != NULL && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID)) |
| 257 | { |
| 258 | found++; |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | if (found == 0 && required > 0) |
| 265 | { |
| 266 | m_record_list.reset(); |
| 267 | return NOTFOUND; |
| 268 | } |
| 269 | |
| 270 | // return a summary |
| 271 | return summarize(list_name); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | //------------------------------------------------- |
| 210 | 276 | // audit_samples - validate the samples for the |
| 211 | 277 | // currently-enumerated driver |
| 212 | 278 | //------------------------------------------------- |