trunk/src/emu/clifront.c
| r18498 | r18499 | |
| 90 | 90 | { CLICOMMAND_LISTSOFTWARE ";lsoft", "0", OPTION_COMMAND, "list known software for the system" }, |
| 91 | 91 | { CLICOMMAND_VERIFYSOFTWARE ";vsoft", "0", OPTION_COMMAND, "verify known software for the system" }, |
| 92 | 92 | { CLICOMMAND_GETSOFTLIST ";glist", "0", OPTION_COMMAND, "retrieve software list by name" }, |
| 93 | { CLICOMMAND_VERIFYSOFTLIST ";vlist", "0", OPTION_COMMAND, "verify software list by name" }, |
| 93 | 94 | { NULL } |
| 94 | 95 | }; |
| 95 | 96 | |
| r18498 | r18499 | |
| 1434 | 1435 | } |
| 1435 | 1436 | |
| 1436 | 1437 | |
| 1438 | /*------------------------------------------------- |
| 1439 | verifysoftlist - verify software list by name |
| 1440 | -------------------------------------------------*/ |
| 1441 | void cli_frontend::verifysoftlist(const char *gamename) |
| 1442 | { |
| 1443 | int_map list_map; |
| 1444 | int correct = 0; |
| 1445 | int incorrect = 0; |
| 1446 | int notfound = 0; |
| 1447 | int matched = 0; |
| 1448 | |
| 1449 | driver_enumerator drivlist(m_options); |
| 1450 | media_auditor auditor(drivlist); |
| 1451 | |
| 1452 | while (drivlist.next()) |
| 1453 | { |
| 1454 | software_list_device_iterator iter(drivlist.config().root_device()); |
| 1455 | for (const software_list_device *swlist = iter.first(); swlist != NULL; swlist = iter.next()) |
| 1456 | { |
| 1457 | software_list *list = software_list_open(m_options, swlist->list_name(), FALSE, NULL); |
| 1458 | if ( list ) |
| 1459 | { |
| 1460 | if ((mame_strwildcmp(swlist->list_name(),gamename)==0) && list_map.add(swlist->list_name(), 0, false) != TMERR_DUPLICATE) |
| 1461 | { |
| 1462 | matched++; |
| 1463 | |
| 1464 | // Get the actual software list contents |
| 1465 | software_list_parse( list, NULL, NULL ); |
| 1466 | |
| 1467 | for ( software_info *swinfo = software_list_find( list, "*", NULL ); swinfo != NULL; swinfo = software_list_find( list, "*", swinfo ) ) |
| 1468 | { |
| 1469 | media_auditor::summary summary = auditor.audit_software(swlist->list_name(), swinfo, AUDIT_VALIDATE_FAST); |
| 1470 | |
| 1471 | // if not found, count that and leave it at that |
| 1472 | if (summary == media_auditor::NOTFOUND) |
| 1473 | { |
| 1474 | notfound++; |
| 1475 | } |
| 1476 | // else display information about what we discovered |
| 1477 | else if(summary != media_auditor::NONE_NEEDED) |
| 1478 | { |
| 1479 | // output the summary of the audit |
| 1480 | astring summary_string; |
| 1481 | auditor.summarize(swinfo->shortname,&summary_string); |
| 1482 | mame_printf_info("%s", summary_string.cstr()); |
| 1483 | |
| 1484 | // display information about what we discovered |
| 1485 | mame_printf_info("romset %s:%s ", swlist->list_name(), swinfo->shortname); |
| 1486 | |
| 1487 | // switch off of the result |
| 1488 | switch (summary) |
| 1489 | { |
| 1490 | case media_auditor::INCORRECT: |
| 1491 | mame_printf_info("is bad\n"); |
| 1492 | incorrect++; |
| 1493 | break; |
| 1494 | |
| 1495 | case media_auditor::CORRECT: |
| 1496 | mame_printf_info("is good\n"); |
| 1497 | correct++; |
| 1498 | break; |
| 1499 | |
| 1500 | case media_auditor::BEST_AVAILABLE: |
| 1501 | mame_printf_info("is best available\n"); |
| 1502 | correct++; |
| 1503 | break; |
| 1504 | |
| 1505 | default: |
| 1506 | break; |
| 1507 | } |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | software_list_close( list ); |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | |
| 1516 | // clear out any cached files |
| 1517 | zip_file_cache_clear(); |
| 1518 | |
| 1519 | // return an error if none found |
| 1520 | if (matched == 0) |
| 1521 | throw emu_fatalerror(MAMERR_NO_SUCH_GAME, "No matching software lists found for '%s'", gamename); |
| 1522 | |
| 1523 | // if we didn't get anything at all, display a generic end message |
| 1524 | if (matched > 0 && correct == 0 && incorrect == 0) |
| 1525 | { |
| 1526 | throw emu_fatalerror(MAMERR_MISSING_FILES, "no romsets found for software list \"%s\"!\n", gamename); |
| 1527 | } |
| 1528 | // otherwise, print a summary |
| 1529 | else |
| 1530 | { |
| 1531 | if (incorrect > 0) |
| 1532 | throw emu_fatalerror(MAMERR_MISSING_FILES, "%d romsets found in %d software lists, %d were OK.\n", correct + incorrect, matched, correct); |
| 1533 | mame_printf_info("%d romsets found in %d software lists, %d romsets were OK.\n", correct, matched, correct); |
| 1534 | } |
| 1535 | } |
| 1536 | |
| 1437 | 1537 | //------------------------------------------------- |
| 1438 | 1538 | // romident - identify ROMs by looking for |
| 1439 | 1539 | // matches in our internal database |
| r18498 | r18499 | |
| 1543 | 1643 | { CLICOMMAND_VERIFYSOFTWARE, &cli_frontend::verifysoftware }, |
| 1544 | 1644 | { CLICOMMAND_ROMIDENT, &cli_frontend::romident }, |
| 1545 | 1645 | { CLICOMMAND_GETSOFTLIST, &cli_frontend::getsoftlist }, |
| 1646 | { CLICOMMAND_VERIFYSOFTLIST, &cli_frontend::verifysoftlist }, |
| 1546 | 1647 | }; |
| 1547 | 1648 | |
| 1548 | 1649 | // find the command |