Пример #1
0
        // operations

        //void check_driver(const game_driver &driver);

        //-------------------------------------------------
        //  check_shared_source - check all drivers that
        //  share the same source file as the given driver
        //-------------------------------------------------
        public void check_shared_source(game_driver driver)
        {
            // initialize
            validate_begin();

            // then iterate over all drivers and check the ones that share the same source file
            m_drivlist.reset();
            while (m_drivlist.next())
            {
                if (strcmp(driver.type.source(), m_drivlist.driver().type.source()) == 0)
                {
                    validate_one(m_drivlist.driver());
                }
            }

            // cleanup
            validate_end();
        }
Пример #2
0
        // 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));
        }
Пример #3
0
        // 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;

            // first walk the parent chain for required ROMs
            parent_rom_vector parentroms = new parent_rom_vector();

            for (var drvindex = driver_list.find(m_enumerator.driver().parent); 0 <= drvindex; drvindex = driver_list.find(driver_list.driver((size_t)drvindex).parent))  //for (auto drvindex = m_enumerator.find(m_enumerator.driver().parent); 0 <= drvindex; drvindex = m_enumerator.find(m_enumerator.driver(drvindex).parent))
            {
                game_driver parent = driver_list.driver((size_t)drvindex);
                LOG(null, "Checking parent {0} for ROM files\n", parent.type.shortname());
                std.vector <rom_entry> roms = rom_build_entries(parent.rom);
                for (Pointer <rom_entry> region = rom_first_region(new Pointer <rom_entry>(roms)); region != null; region = rom_next_region(region)) //for (rom_entry const *region = rom_first_region(&roms.front()); region; region = rom_next_region(region))
                {
                    for (Pointer <rom_entry> rom = rom_first_file(region); rom != null; rom = rom_next_file(rom))                                    //for (rom_entry const *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
                    {
                        LOG(null, "Adding parent ROM {0}\n", rom.op.name());
                        parentroms.emplace_back(new parent_rom(parent.type, rom));
                    }
                }
            }

            parentroms.remove_redundant_parents();

            // count ROMs required/found
            size_t found           = 0;
            size_t required        = 0;
            size_t shared_found    = 0;
            size_t shared_required = 0;
            size_t parent_found    = 0;

            // iterate over devices and regions
            std.vector <string> searchpath = new std.vector <string>();
            foreach (device_t device in new device_enumerator(m_enumerator.config().root_device()))
            {
                searchpath.clear();

                // now iterate over regions and ROMs within
                for (Pointer <rom_entry> region = rom_first_region(device); region != null; region = rom_next_region(region))
                {
                    for (Pointer <rom_entry> rom = rom_first_file(region); rom != null; rom = rom_next_file(rom))
                    {
                        if (searchpath.empty())
                        {
                            LOG(null, "Audit media for device {0}({1})\n", device.shortname(), device.tag());
                            searchpath = device.searchpath();
                        }

                        // look for a matching parent or device ROM
                        string name = rom.op.name();
                        util.hash_collection hashes = new util.hash_collection(rom.op.hashdata());
                        bool        dumped          = !hashes.flag(util.hash_collection.FLAG_NO_DUMP);
                        device_type shared_device   = parentroms.find_shared_device(device, name, hashes, rom_file_size(rom));
                        if (shared_device != null)
                        {
                            LOG(null, "File '{0}' {1}{2}dumped shared with {3}\n", name, ROM_ISOPTIONAL(rom.op) ? "optional " : "", dumped ? "" : "un", shared_device.shortname());
                        }
                        else
                        {
                            LOG(null, "File '{0}' {1}{2}dumped\n", name, ROM_ISOPTIONAL(rom.op) ? "optional " : "", dumped ? "" : "un");
                        }

                        // count the number of files with hashes
                        if (dumped && !ROM_ISOPTIONAL(rom.op))
                        {
                            required++;
                            if (shared_device != null)
                            {
                                shared_required++;
                            }
                        }

                        // audit a file
                        audit_record record = null;
                        if (ROMREGION_ISROMDATA(region.op))
                        {
                            record = audit_one_rom(searchpath, rom);
                        }

                        // audit a disk
                        else if (ROMREGION_ISDISKDATA(region.op))
                        {
                            record = audit_one_disk(rom, device);
                        }

                        if (record != null)
                        {
                            // see if the actual content found belongs to a parent
                            var matchesshared = parentroms.actual_matches_shared(device, record);
                            if (matchesshared.first != null)
                            {
                                LOG(null, "Actual ROM file shared with {0}parent {1}\n", matchesshared.second ? "immediate " : "", matchesshared.first.shortname());
                            }

                            // count the number of files that are found.
                            if ((record.status() == audit_status.GOOD) || ((record.status() == audit_status.FOUND_INVALID) && (matchesshared.first == null)))
                            {
                                found++;
                                if (shared_device != null)
                                {
                                    shared_found++;
                                }
                                if (matchesshared.second)
                                {
                                    parent_found++;
                                }
                            }

                            record.set_shared_device(shared_device);
                        }
                    }
                }
            }

            if (!searchpath.empty())
            {
                LOG(null, "Total required={0} (shared={1}) found={2} (shared={3} parent={4})\n", required, shared_required, found, shared_found, parent_found);
            }

            // 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) || parent_found == 0))
            {
                m_record_list.clear();
                return(summary.NOTFOUND);
            }

            // return a summary
            return(summarize(m_enumerator.driver().name));
        }