예제 #1
0
 public path_iterator(path_iterator that)
 {
     m_searchpath = that.m_searchpath;
     m_currentIdx = that.m_currentIdx;  //, m_current(std::next(m_searchpath.cbegin(), std::distance(that.m_searchpath.cbegin(), that.m_current)))
     m_separator  = that.m_separator;
     m_is_first   = that.m_is_first;
 }
예제 #2
0
        public emu_file(string searchpath, u32 openflags)
        {
            m_file                  = null;
            m_iterator              = new path_iterator(searchpath);
            m_mediapaths            = new path_iterator(searchpath);
            m_crc                   = 0;
            m_openflags             = openflags;
            m_zipfile               = null;
            m_ziplength             = 0;
            m_remove_on_close       = false;
            m_restrict_to_mediapath = false;


            // sanity check the open flags
            if ((m_openflags & OPEN_FLAG_HAS_CRC) > 0 && (m_openflags & OPEN_FLAG_WRITE) > 0)
            {
                throw new emu_fatalerror("Attempted to open a file for write with OPEN_FLAG_HAS_CRC");
            }
        }
예제 #3
0
파일: audit.cs 프로젝트: kwanboy/mcs
        // 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);
        }
예제 #4
0
        //-------------------------------------------------
        //  start_luaengine
        //-------------------------------------------------
        public void start_luaengine()
        {
            if (options().plugins())
            {
                //throw new emu_unimplemented();
#if false
                // scan all plugin directories
                path_iterator iter = new path_iterator(options().plugins_path());
                string        pluginpath;
                while (iter.next(out pluginpath))
                {
                    // user may specify environment variables; subsitute them
                    m_osdcore.osd_subst_env(out pluginpath, pluginpath);

                    // and then scan the directory recursively
                    m_plugins.scan_directory(pluginpath, true);
                }

                {
                    // parse the file
                    // attempt to open the output file
                    emu_file file = new emu_file(options().ini_path(), OPEN_FLAG_READ);
                    if (file.open("plugin.ini") == osd_file.error.NONE)
                    {
                        try
                        {
                            m_plugins.parse_ini_file(file.core_file_get());  //(util::core_file&)file
                        }
                        catch (options_exception)
                        {
                            osd_printf_error("**Error loading plugin.ini**\n");
                        }

                        file.close();
                    }
                }

                // process includes
                foreach (string incl in split(options().plugin(), ','))
                {
                    plugin_options::plugin *p = m_plugins->find(incl);
                    if (!p)
                    {
                        fatalerror("Fatal error: Could not load plugin: %s\n", incl);
                    }
                    p.m_start = true;
                }

                // process excludes
                foreach (string excl in split(options().no_plugin(), ','))
                {
                    plugin_options::plugin *p = m_plugins->find(excl);
                    if (!p)
                    {
                        fatalerror("Fatal error: Unknown plugin: %s\n", excl);
                    }
                    p.m_start = false;
                }
#endif
            }

            // we have a special way to open the console plugin
            if (options().console())
            {
                plugin_options.plugin p = m_plugins.find(OPTION_CONSOLE);
                if (p == null)
                {
                    fatalerror("Fatal error: Console plugin not found.\n");
                }

                p.m_start = true;
            }

            m_lua.initialize();

            {
                emu_file            file   = new emu_file(options().plugins_path(), OPEN_FLAG_READ);
                std.error_condition filerr = file.open("boot.lua");
                if (!filerr)
                {
                    string exppath;
                    m_osdcore.osd_subst_env(out exppath, file.fullpath());
                    m_lua.load_script(file.fullpath());
                    file.close();
                }
            }
        }
예제 #5
0
 // construction/destruction
 //-------------------------------------------------
 //  file_enumerator - constructor
 //-------------------------------------------------
 public file_enumerator(string searchpath)
 {
     m_iterator = new path_iterator(searchpath);
 }
예제 #6
0
 emu_file(path_iterator searchpath, u32 openflags) : this(openflags, empty_t.EMPTY)
 {
     m_iterator.emplace_back(new std.pair <path_iterator, string>(new path_iterator(searchpath), ""));
     m_mediapaths.emplace_back(new std.pair <path_iterator, string>(new path_iterator(searchpath), ""));
 }
예제 #7
0
        public void start_luaengine()
        {
            if (options().plugins())
            {
                path_iterator iter = new path_iterator(options().plugins_path());
                string        pluginpath;
                while (iter.next(out pluginpath))
                {
                    m_plugins.parse_json(pluginpath);
                }

                string [] include = options().plugin() == null ? new string[0] : options().plugin().Split(',');  // split(options().plugin(),',');
                string [] exclude = options().no_plugin() == null ? new string[0] : options().no_plugin().Split(',');

                {
                    // parse the file
                    // attempt to open the output file
                    emu_file file = new emu_file(options().ini_path(), OPEN_FLAG_READ);
                    if (file.open("plugin.ini") == osd_file.error.NONE)
                    {
                        try
                        {
                            m_plugins.parse_ini_file(file.core_file_get(), mame_options.OPTION_PRIORITY_MAME_INI, mame_options.OPTION_PRIORITY_MAME_INI < mame_options.OPTION_PRIORITY_DRIVER_INI, false);
                        }
                        catch (options_exception)
                        {
                            osd_printf_error("**Error loading plugin.ini**\n");
                        }

                        file.close();
                    }
                }

                foreach (var curentry in m_plugins.entries())
                {
                    if (curentry.type() != core_options.option_type.HEADER)
                    {
                        if (Array.Exists(include, s => s == curentry.name()))  // std::find(include.begin(), include.end(), curentry.name()) != include.end())
                        {
                            m_plugins.set_value(curentry.name(), "1", emu_options.OPTION_PRIORITY_CMDLINE);
                        }

                        if (Array.Exists(exclude, s => s == curentry.name()))  // std::find(exclude.begin(), exclude.end(), curentry.name()) != exclude.end())
                        {
                            m_plugins.set_value(curentry.name(), "0", emu_options.OPTION_PRIORITY_CMDLINE);
                        }
                    }
                }
            }

            if (options().console())
            {
                m_plugins.set_value("console", "1", emu_options.OPTION_PRIORITY_CMDLINE);
                if (m_plugins.exists(emu_options.OPTION_CONSOLE))
                {
                    m_plugins.set_value(emu_options.OPTION_CONSOLE, "1", emu_options.OPTION_PRIORITY_CMDLINE);
                }
                else
                {
                    fatalerror("Console plugin not found.\n");
                }
            }

            m_lua.initialize();

            {
                emu_file       file   = new emu_file(options().plugins_path(), OPEN_FLAG_READ);
                osd_file.error filerr = file.open("boot.lua");
                if (filerr == osd_file.error.NONE)
                {
                    string exppath;
                    osdcore_global.m_osdcore.osd_subst_env(out exppath, file.fullpath());
                    m_lua.load_script(file.fullpath());
                    file.close();
                }
            }
        }
예제 #8
0
파일: audit.cs 프로젝트: kwanboy/mcs
        //-------------------------------------------------
        //  audit_samples - validate the samples for the
        //  currently-enumerated driver
        //-------------------------------------------------
        public summary audit_samples()
        {
            // start fresh
            m_record_list.clear();

            int required = 0;
            int found    = 0;

            // iterate over sample entries
            foreach (samples_device device in new samples_device_iterator(m_enumerator.config().root_device()))
            {
                // by default we just search using the driver name
                string searchpath = m_enumerator.driver().name;

                // add the alternate path if present
                samples_iterator samplesiter = new samples_iterator(device);
                if (samplesiter.altbasename() != null)
                {
                    searchpath += ";" + samplesiter.altbasename();
                }

                // iterate over samples in this entry
                for (string samplename = samplesiter.first(); samplename != null; samplename = samplesiter.next())
                {
                    required++;

                    // create a new record
                    audit_record record = m_record_list.emplace_back(new audit_record(samplename, audit_record.media_type.MEDIA_SAMPLE)).Value;  //audit_record &record = *m_record_list.emplace(m_record_list.end(), samplename, media_type::SAMPLE);

                    // look for the files
                    emu_file      file = new emu_file(m_enumerator.options().sample_path(), osdcore_global.OPEN_FLAG_READ | osdcore_global.OPEN_FLAG_NO_PRELOAD);
                    path_iterator path = new path_iterator(searchpath);
                    string        curpath;
                    while (path.next(out curpath, samplename))
                    {
                        // attempt to access the file (.flac) or (.wav)
                        osd_file.error filerr = file.open(curpath, ".flac");
                        if (filerr != osd_file.error.NONE)
                        {
                            filerr = file.open(curpath, ".wav");
                        }

                        if (filerr == osd_file.error.NONE)
                        {
                            record.set_status(audit_record.audit_status.STATUS_GOOD, audit_record.audit_substatus.SUBSTATUS_GOOD);
                            found++;
                        }
                        else
                        {
                            record.set_status(audit_record.audit_status.STATUS_NOT_FOUND, audit_record.audit_substatus.SUBSTATUS_NOT_FOUND);
                        }
                    }

                    file.close();
                }
            }

            if (found == 0 && required > 0)
            {
                m_record_list.clear();
                return(summary.NOTFOUND);
            }

            // return a summary
            string unused = "";

            return(summarize(m_enumerator.driver().name, ref unused));
        }