using System.Collections.Generic; using Mono.Data.Sqlite; using SabreTools.Helper; namespace SabreTools { public partial class DATabase { /// /// Wrap generating a DAT from the library /// /// System ID to be used in the DAT (blank means all) /// True if files should not be renamed with system and/or source in merged mode (default false) /// True if the output file should be in ClrMamePro format (default false) private static void InitGenerate(string systemid, bool norename, bool old) { IGenerate gen = new GenerateTwo(systemid, "" /* sourceid */, _datroot, _outroot, _connectionString, _logger, norename, old); gen.Export(); } /// /// Wrap generating all standard DATs from the library /// private static void InitGenerateAll(bool norename, bool old) { List systems = new List(); using (SqliteConnection dbc = new SqliteConnection(_connectionString)) { dbc.Open(); string query = "SELECT id FROM system"; using (SqliteCommand slc = new SqliteCommand(query, dbc)) { using (SqliteDataReader sldr = slc.ExecuteReader()) { // If nothing is found, tell the user and exit if (!sldr.HasRows) { _logger.Warning("No systems found! Please add a system and then try again."); return; } while (sldr.Read()) { systems.Add(sldr.GetInt32(0).ToString()); } } } // Loop through the inputs foreach (string system in systems) { _logger.User("Generating DAT for system id " + system); InitGenerate(system, norename, old); } } } } }