public std.error_condition initialize() { #if false try { if (m_utf16_buf.size() < 128) { m_utf16_buf.resize(128); } if (m_uchar_buf.size() < 128) { m_uchar_buf.resize(128); } m_utf8_buf.reserve(512); } catch (...) { return(std::errc::not_enough_memory); } #endif if (m_archive_stream.file == null) { osd_file file; //osd_file::ptr file; std.error_condition err = m_osdfile.open(m_filename, OPEN_FLAG_READ, out file, out m_archive_stream.length); //std::error_condition const err = osd_file::open(m_filename, OPEN_FLAG_READ, file, m_archive_stream.length); if (err) { return(err); } m_archive_stream.file = osd_file_read(file); //m_archive_stream.file = osd_file_read(std::move(file)); //osd_printf_verbose("un7z: opened archive file %s\n", m_filename); } else if (m_archive_stream.length == 0) { std.error_condition err = m_archive_stream.file.length(out m_archive_stream.length); //std::error_condition const err = m_archive_stream.file->length(m_archive_stream.length); if (err) { osd_printf_verbose( "un7z: error getting length of archive file {0} ({1}:{2} {3})\n", m_filename, err.category().name(), err.value(), err.message()); return(err); } }
//------------------------------------------------- // load_samples - load all the samples in our // attached interface // Returns true when all samples were successfully read, else false //------------------------------------------------- bool load_samples() { bool ok = true; // if the user doesn't want to use samples, bail if (!machine().options().samples()) { return(false); } // iterate over ourself string basename = machine().basename(); samples_iterator iter = new samples_iterator(this); string altbasename = iter.altbasename(); // pre-size the array m_sample.resize((size_t)iter.count()); // load the samples int index = 0; for (string samplename = iter.first(); samplename != null; index++, samplename = iter.next()) { // attempt to open as FLAC first emu_file file = new emu_file(machine().options().sample_path(), OPEN_FLAG_READ); std.error_condition filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.flac", basename, samplename)); if (filerr && !string.IsNullOrEmpty(altbasename)) { filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.flac", altbasename, samplename)); } // if not, try as WAV if (filerr) { filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.wav", basename, samplename)); } if (filerr && !string.IsNullOrEmpty(altbasename)) { filerr = file.open(util.string_format("{0}" + PATH_SEPARATOR + "{1}.wav", altbasename, samplename)); } // if opened, read it if (!filerr) { read_sample(file, m_sample[index]); } else { logerror("Error opening sample '{0}' ({1}:{2} {3})\n", samplename, filerr.category().name(), filerr.value(), filerr.message()); ok = false; } file.close(); } return(ok); }
/************************************* * * Settings save/load frontend * *************************************/ public bool load_settings() { // loop over all registrants and call their init function foreach (var type in m_typelist) { type.load(config_type.INIT, config_level.DEFAULT, null); } // now load the controller file string controller = machine().options().ctrlr(); if (!string.IsNullOrEmpty(controller)) { // open the config file emu_file file = new emu_file(machine().options().ctrlr_path(), OPEN_FLAG_READ); osd_printf_verbose("Attempting to parse: {0}.cfg\n", controller); std.error_condition filerr = file.open(controller + ".cfg"); if (filerr) { throw new emu_fatalerror("Could not open controller file {0}.cfg ({1}:{2} {3})", controller, filerr.category().name(), filerr.value(), filerr.message()); } // load the XML if (!load_xml(file, config_type.CONTROLLER)) { throw new emu_fatalerror("Could not load controller file {0}.cfg", controller); } file.close(); } bool loaded; { // next load the defaults file emu_file file = new emu_file(machine().options().cfg_directory(), OPEN_FLAG_READ); std.error_condition filerr = file.open("default.cfg"); osd_printf_verbose("Attempting to parse: default.cfg\n"); if (!filerr) { load_xml(file, config_type.DEFAULT); } // finally, load the game-specific file filerr = file.open(machine().basename() + ".cfg"); osd_printf_verbose("Attempting to parse: {0}.cfg\n", machine().basename()); loaded = !filerr && load_xml(file, config_type.SYSTEM); file.close(); } // loop over all registrants and call their final function foreach (var type in m_typelist) { type.load(config_type.FINAL, config_level.DEFAULT, null); } // if we didn't find a saved config, return false so the main core knows that it // is the first time the game is run and it should display the disclaimer. return(loaded); }