diff --git a/.gitignore b/.gitignore index 7022312e..db7df3f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ /.vs +/CommandVault/obj +/CommandVault/obj/Debug +/CommandVault/obj/Release /Deheader/obj /Deheader/obj/Debug /Deheader/obj/Release diff --git a/Deheader/Headerer.cs b/Deheader/Headerer.cs index e28aa4a5..ada40809 100644 --- a/Deheader/Headerer.cs +++ b/Deheader/Headerer.cs @@ -157,7 +157,7 @@ namespace SabreTools logger.User("Unheadered file created!"); // Now add the information to the database if it's not already there - RomData rom = RomTools.GetSingleFileInfo(file + ".new"); + Rom rom = RomTools.GetSingleFileInfo(file + ".new"); AddHeaderToDatabase(hstr, rom.SHA1, type); } } @@ -209,7 +209,7 @@ namespace SabreTools private static void ReplaceHeader(string file) { // First, get the SHA-1 hash of the file - RomData rom = RomTools.GetSingleFileInfo(file); + Rom rom = RomTools.GetSingleFileInfo(file); // Then try to pull the corresponding headers from the database string header = ""; diff --git a/SabreTools.Helper/Data/Structs.cs b/SabreTools.Helper/Data/Structs.cs index 1836d7d2..16a62d76 100644 --- a/SabreTools.Helper/Data/Structs.cs +++ b/SabreTools.Helper/Data/Structs.cs @@ -6,7 +6,7 @@ namespace SabreTools.Helper /// /// Intermediate struct for holding and processing rom data /// - public struct RomData : IComparable, IEquatable + public struct Rom : IComparable, IEquatable { public string Game; public string Name; @@ -24,7 +24,7 @@ namespace SabreTools.Helper { try { - RomData comp = (RomData)obj; + Rom comp = (Rom)obj; if (this.Game == comp.Game) { @@ -42,7 +42,7 @@ namespace SabreTools.Helper } } - public bool Equals(RomData other) + public bool Equals(Rom other) { return (this.Game == other.Game && this.Name == other.Name && @@ -64,7 +64,7 @@ namespace SabreTools.Helper /// /// Intermediate struct for holding DAT information /// - public struct DatData : ICloneable + public struct Dat : ICloneable { // Data common to most DAT types public string FileName; @@ -85,7 +85,7 @@ namespace SabreTools.Helper public ForcePacking ForcePacking; public OutputFormat OutputFormat; public bool MergeRoms; - public Dictionary> Roms; + public Dictionary> Roms; // Data specific to the Miss DAT type public bool UseGame; @@ -109,7 +109,7 @@ namespace SabreTools.Helper public object Clone() { - return new DatData + return new Dat { FileName = this.FileName, Name = this.Name, diff --git a/SabreTools.Helper/Tools/ArchiveTools.cs b/SabreTools.Helper/Tools/ArchiveTools.cs index 71cbf827..19397260 100644 --- a/SabreTools.Helper/Tools/ArchiveTools.cs +++ b/SabreTools.Helper/Tools/ArchiveTools.cs @@ -18,7 +18,7 @@ namespace SabreTools.Helper /// Input filename to be moved /// Output directory to build to /// RomData representing the new information - public static void WriteToArchive(string input, string output, RomData rom) + public static void WriteToArchive(string input, string output, Rom rom) { string archiveFileName = output + Path.DirectorySeparatorChar + rom.Game + ".zip"; @@ -311,9 +311,9 @@ namespace SabreTools.Helper /// Input file to get data from /// Logger object for file and console output /// List of RomData objects representing the found data - public static List GetArchiveFileInfo(string input, Logger logger) + public static List GetArchiveFileInfo(string input, Logger logger) { - List roms = new List(); + List roms = new List(); string gamename = Path.GetFileNameWithoutExtension(input); // First get the archive type @@ -339,7 +339,7 @@ namespace SabreTools.Helper { logger.Log("Entry found: '" + reader.Entry.Key + "': " + reader.Entry.Size + ", " + reader.Entry.Crc.ToString("X").ToLowerInvariant()); - roms.Add(new RomData + roms.Add(new Rom { Type = "rom", Name = reader.Entry.Key, @@ -369,7 +369,7 @@ namespace SabreTools.Helper /// Filename to get information from /// Logger object for file and console output /// Populated RomData object if success, empty one on error - public static RomData GetTorrentGZFileInfo(string input, Logger logger) + public static Rom GetTorrentGZFileInfo(string input, Logger logger) { string datum = Path.GetFileName(input).ToLowerInvariant(); long filesize = new FileInfo(input).Length; @@ -378,14 +378,14 @@ namespace SabreTools.Helper if (!Regex.IsMatch(datum, @"^[0-9a-f]{40}\.gz")) { logger.Warning("Non SHA-1 filename found, skipping: '" + datum + "'"); - return new RomData(); + return new Rom(); } // Check if the file is at least the minimum length if (filesize < 32 /* bytes */) { logger.Warning("Possibly corrupt file '" + input + "' with size " + Style.GetBytesReadable(filesize)); - return new RomData(); + return new Rom(); } // Get the Romba-specific header data @@ -430,7 +430,7 @@ namespace SabreTools.Helper } } - RomData rom = new RomData + Rom rom = new Rom { Type = "rom", Game = Path.GetFileNameWithoutExtension(input), diff --git a/SabreTools.Helper/Tools/DatTools.cs b/SabreTools.Helper/Tools/DatTools.cs index c2ea1876..8417e268 100644 --- a/SabreTools.Helper/Tools/DatTools.cs +++ b/SabreTools.Helper/Tools/DatTools.cs @@ -77,7 +77,7 @@ namespace SabreTools.Helper /// True if full pathnames are to be kept, false otherwise (default) /// True if game names are sanitized, false otherwise (default) /// DatData object representing the read-in data - public static DatData Parse(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep = false, bool clean = false) + public static Dat Parse(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep = false, bool clean = false) { // If the output filename isn't set already, get the internal filename if (String.IsNullOrEmpty(datdata.FileName)) @@ -94,7 +94,7 @@ namespace SabreTools.Helper // Make sure there's a dictionary to read to if (datdata.Roms == null) { - datdata.Roms = new Dictionary>(); + datdata.Roms = new Dictionary>(); } // Now parse the correct type of DAT @@ -123,7 +123,7 @@ namespace SabreTools.Helper /// True if full pathnames are to be kept, false otherwise (default) /// True if game names are sanitized, false otherwise (default) /// DatData object representing the read-in data - public static DatData ParseCMP(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep, bool clean) + public static Dat ParseCMP(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean) { // Read the input file, if possible logger.Log("Attempting to read file: \"" + filename + "\""); @@ -169,7 +169,7 @@ namespace SabreTools.Helper // If we're in cleaning mode, sanitize the game name gamename = (clean ? Style.CleanGameName(gamename) : gamename); - RomData rom = new RomData + Rom rom = new Rom { Game = gamename, Type = (line.Trim().StartsWith("disk (") ? "disk" : "rom"), @@ -339,7 +339,7 @@ namespace SabreTools.Helper } else { - List templist = new List(); + List templist = new List(); templist.Add(rom); datdata.Roms.Add(key, templist); } @@ -455,7 +455,7 @@ namespace SabreTools.Helper /// Logger object for console and/or file output /// True if game names are sanitized, false otherwise (default) /// DatData object representing the read-in data - public static DatData ParseRC(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool clean) + public static Dat ParseRC(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool clean) { // Read the input file, if possible logger.Log("Attempting to read file: \"" + filename + "\""); @@ -570,7 +570,7 @@ namespace SabreTools.Helper // If we're in cleaning mode, sanitize the game name rominfo[3] = (clean ? Style.CleanGameName(rominfo[3]) : rominfo[3]); - RomData rom = new RomData + Rom rom = new Rom { Game = rominfo[3], Name = rominfo[5], @@ -640,7 +640,7 @@ namespace SabreTools.Helper } else { - List templist = new List(); + List templist = new List(); templist.Add(rom); datdata.Roms.Add(key, templist); } @@ -674,7 +674,7 @@ namespace SabreTools.Helper /// True if full pathnames are to be kept, false otherwise (default) /// True if game names are sanitized, false otherwise (default) /// DatData object representing the read-in data - public static DatData ParseXML(string filename, int sysid, int srcid, DatData datdata, Logger logger, bool keep, bool clean) + public static Dat ParseXML(string filename, int sysid, int srcid, Dat datdata, Logger logger, bool keep, bool clean) { // Prepare all internal variables XmlReader subreader, headreader, flagreader; @@ -700,7 +700,7 @@ namespace SabreTools.Helper // If we're in cleaning mode, sanitize the game name tempgame = (clean ? Style.CleanGameName(tempgame) : tempgame); - RomData rom = new RomData + Rom rom = new Rom { Type = "rom", Name = "null", @@ -718,7 +718,7 @@ namespace SabreTools.Helper } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdata.Roms.Add(key, temp); } @@ -1090,7 +1090,7 @@ namespace SabreTools.Helper if (subreader.GetAttribute("loadflag") == "continue" || subreader.GetAttribute("loadflag") == "ignore") { int index = datdata.Roms[key].Count() - 1; - RomData lastrom = datdata.Roms[key][index]; + Rom lastrom = datdata.Roms[key][index]; lastrom.Size += size; datdata.Roms[key].RemoveAt(index); datdata.Roms[key].Add(lastrom); @@ -1145,7 +1145,7 @@ namespace SabreTools.Helper // Get the new values to add key = size + "-" + crc; - RomData rom = new RomData + Rom rom = new Rom { Game = tempname, Name = subreader.GetAttribute("name"), @@ -1165,7 +1165,7 @@ namespace SabreTools.Helper } else { - List newvalue = new List(); + List newvalue = new List(); newvalue.Add(rom); datdata.Roms.Add(key, newvalue); } @@ -1197,7 +1197,7 @@ namespace SabreTools.Helper // If we're in cleaning mode, sanitize the game name tempname = (clean ? Style.CleanGameName(tempname.Split(Path.DirectorySeparatorChar)) : tempname); - RomData rom = new RomData + Rom rom = new Rom { Type = "rom", Name = "null", @@ -1215,7 +1215,7 @@ namespace SabreTools.Helper } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdata.Roms.Add(key, temp); } @@ -1316,7 +1316,7 @@ namespace SabreTools.Helper if (xtr.GetAttribute("loadflag") == "continue" || xtr.GetAttribute("loadflag") == "ignore") { int index = datdata.Roms[key].Count() - 1; - RomData lastrom = datdata.Roms[key][index]; + Rom lastrom = datdata.Roms[key][index]; lastrom.Size += size; datdata.Roms[key].RemoveAt(index); datdata.Roms[key].Add(lastrom); @@ -1380,7 +1380,7 @@ namespace SabreTools.Helper // Get the new values to add key = size + "-" + crc; - RomData rom = new RomData + Rom rom = new Rom { Game = tempname, Name = xtr.GetAttribute("name"), @@ -1400,7 +1400,7 @@ namespace SabreTools.Helper } else { - List newvalue = new List(); + List newvalue = new List(); newvalue.Add(rom); datdata.Roms.Add(key, newvalue); } @@ -1438,9 +1438,9 @@ namespace SabreTools.Helper /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise /// SortedDictionary bucketed by game name - public static SortedDictionary> BucketByGame(List list, bool mergeroms, bool norename, Logger logger, bool output = true) + public static SortedDictionary> BucketByGame(List list, bool mergeroms, bool norename, Logger logger, bool output = true) { - Dictionary> dict = new Dictionary>(); + Dictionary> dict = new Dictionary>(); dict.Add("key", list); return BucketByGame(dict, mergeroms, norename, logger, output); } @@ -1454,9 +1454,9 @@ namespace SabreTools.Helper /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise /// SortedDictionary bucketed by game name - public static SortedDictionary> BucketByGame(IDictionary> dict, bool mergeroms, bool norename, Logger logger, bool output = true) + public static SortedDictionary> BucketByGame(IDictionary> dict, bool mergeroms, bool norename, Logger logger, bool output = true) { - SortedDictionary> sortable = new SortedDictionary>(); + SortedDictionary> sortable = new SortedDictionary>(); long count = 0; // If we have a null dict or an empty one, output a new dictionary @@ -1466,15 +1466,15 @@ namespace SabreTools.Helper } // Process each all of the roms - foreach (List roms in dict.Values) + foreach (List roms in dict.Values) { - List newroms = roms; + List newroms = roms; if (mergeroms) { newroms = RomTools.Merge(newroms, logger); } - foreach (RomData rom in newroms) + foreach (Rom rom in newroms) { count++; string key = (norename ? "" : rom.Metadata.SystemID.ToString().PadLeft(10, '0') + "-" + rom.Metadata.SourceID.ToString().PadLeft(10, '0') + "-") + rom.Game.ToLowerInvariant(); @@ -1484,7 +1484,7 @@ namespace SabreTools.Helper } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); sortable.Add(key, temp); } @@ -1509,9 +1509,9 @@ namespace SabreTools.Helper /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise /// SortedDictionary bucketed by size and hash - public static SortedDictionary> BucketByHashSize(List list, bool mergeroms, bool norename, Logger logger, bool output = true) + public static SortedDictionary> BucketByHashSize(List list, bool mergeroms, bool norename, Logger logger, bool output = true) { - Dictionary> dict = new Dictionary>(); + Dictionary> dict = new Dictionary>(); dict.Add("key", list); return BucketByHashSize(dict, mergeroms, norename, logger, output); } @@ -1525,9 +1525,9 @@ namespace SabreTools.Helper /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise /// SortedDictionary bucketed by size and hash - public static SortedDictionary> BucketByHashSize(IDictionary> dict, bool mergeroms, bool norename, Logger logger, bool output = true) + public static SortedDictionary> BucketByHashSize(IDictionary> dict, bool mergeroms, bool norename, Logger logger, bool output = true) { - SortedDictionary> sortable = new SortedDictionary>(); + SortedDictionary> sortable = new SortedDictionary>(); long count = 0; // If we have a null dict or an empty one, output a new dictionary @@ -1537,15 +1537,15 @@ namespace SabreTools.Helper } // Process each all of the roms - foreach (List roms in dict.Values) + foreach (List roms in dict.Values) { - List newroms = roms; + List newroms = roms; if (mergeroms) { newroms = RomTools.Merge(newroms, logger); } - foreach (RomData rom in newroms) + foreach (Rom rom in newroms) { count++; string key = rom.Size + "-" + rom.CRC; ; @@ -1555,7 +1555,7 @@ namespace SabreTools.Helper } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); sortable.Add(key, temp); } @@ -1589,7 +1589,7 @@ namespace SabreTools.Helper /// SHA-1 of the rom to match (can use asterisk-partials) /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) /// Logging object for console and file output - public static void Update(string inputFileName, DatData datdata, string outputDirectory, bool clean, string gamename, string romname, + public static void Update(string inputFileName, Dat datdata, string outputDirectory, bool clean, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger) { // Clean the input string @@ -1620,7 +1620,7 @@ namespace SabreTools.Helper foreach (string file in Directory.EnumerateFiles(inputFileName, "*", SearchOption.AllDirectories)) { logger.User("Processing \"" + Path.GetFullPath(file).Remove(0, inputFileName.Length) + "\""); - DatData innerDatdata = (DatData)datdata.Clone(); + Dat innerDatdata = (Dat)datdata.Clone(); innerDatdata.Roms = null; innerDatdata = Parse(file, 0, 0, innerDatdata, logger, true, clean); innerDatdata = Filter(innerDatdata, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, logger); @@ -1658,16 +1658,16 @@ namespace SabreTools.Helper /// Select roms with nodump status as follows: null (match all), true (match Nodump only), false (exclude Nodump) /// Logging object for console and file output /// Returns filtered DatData object - public static DatData Filter(DatData datdata, string gamename, string romname, string romtype, long sgt, + public static Dat Filter(Dat datdata, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, Logger logger) { // Now loop through and create a new Rom dictionary using filtered values - Dictionary> dict = new Dictionary>(); + Dictionary> dict = new Dictionary>(); List keys = datdata.Roms.Keys.ToList(); foreach (string key in keys) { - List roms = datdata.Roms[key]; - foreach (RomData rom in roms) + List roms = datdata.Roms[key]; + foreach (Rom rom in roms) { // Filter on nodump status if (nodump == true && !rom.Nodump) @@ -1794,7 +1794,7 @@ namespace SabreTools.Helper } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); dict.Add(key, temp); } diff --git a/SabreTools.Helper/Tools/Output.cs b/SabreTools.Helper/Tools/Output.cs index 3e1caf2d..46ace61c 100644 --- a/SabreTools.Helper/Tools/Output.cs +++ b/SabreTools.Helper/Tools/Output.cs @@ -23,7 +23,7 @@ namespace SabreTools.Helper /// - Have the ability to strip special (non-ASCII) characters from rom information /// - Add a flag for ignoring roms with blank sizes /// - public static bool WriteDatfile(DatData datdata, string outDir, Logger logger, bool norename = true, bool stats = false) + public static bool WriteDatfile(Dat datdata, string outDir, Logger logger, bool norename = true, bool stats = false) { // Output initial statistics, for kicks if (stats) @@ -32,7 +32,7 @@ namespace SabreTools.Helper } // Bucket roms by game name and optionally dedupe - SortedDictionary> sortable = DatTools.BucketByGame(datdata.Roms, datdata.MergeRoms, norename, logger); + SortedDictionary> sortable = DatTools.BucketByGame(datdata.Roms, datdata.MergeRoms, norename, logger); // Now write out to file // If it's empty, use the current folder @@ -61,11 +61,11 @@ namespace SabreTools.Helper int depth = 2, last = -1; string lastgame = null; List splitpath = new List(); - foreach (List roms in sortable.Values) + foreach (List roms in sortable.Values) { for (int index = 0; index < roms.Count; index++) { - RomData rom = roms[index]; + Rom rom = roms[index]; List newsplit = rom.Game.Split('\\').ToList(); // If we have a different game and we're not at the start of the list, output the end of last item @@ -136,7 +136,7 @@ namespace SabreTools.Helper /// DatData object representing DAT information /// Logger object for file and console output /// True if the data was written, false on error - public static bool WriteHeader(StreamWriter sw, DatData datdata, Logger logger) + public static bool WriteHeader(StreamWriter sw, Dat datdata, Logger logger) { try { @@ -244,7 +244,7 @@ namespace SabreTools.Helper /// Last known depth to cycle back from (SabreDAT only) /// Logger object for file and console output /// The new depth of the tag - public static int WriteStartGame(StreamWriter sw, RomData rom, List newsplit, string lastgame, DatData datdata, int depth, int last, Logger logger) + public static int WriteStartGame(StreamWriter sw, Rom rom, List newsplit, string lastgame, Dat datdata, int depth, int last, Logger logger) { try { @@ -303,7 +303,7 @@ namespace SabreTools.Helper /// Last known depth to cycle back from (SabreDAT only) /// Logger object for file and console output /// The new depth of the tag - public static int WriteEndGame(StreamWriter sw, RomData rom, List splitpath, List newsplit, string lastgame, DatData datdata, int depth, out int last, Logger logger) + public static int WriteEndGame(StreamWriter sw, Rom rom, List splitpath, List newsplit, string lastgame, Dat datdata, int depth, out int last, Logger logger) { last = 0; @@ -372,7 +372,7 @@ namespace SabreTools.Helper /// Current depth to output file at (SabreDAT only) /// Logger object for file and console output /// True if the data was written, false on error - public static bool WriteRomData(StreamWriter sw, RomData rom, string lastgame, DatData datdata, int depth, Logger logger) + public static bool WriteRomData(StreamWriter sw, Rom rom, string lastgame, Dat datdata, int depth, Logger logger) { try { @@ -505,7 +505,7 @@ namespace SabreTools.Helper /// /// Current depth to output file at (SabreDAT only) /// Logger object for file and console output /// True if the data was written, false on error - public static bool WriteFooter(StreamWriter sw, DatData datdata, int depth, Logger logger) + public static bool WriteFooter(StreamWriter sw, Dat datdata, int depth, Logger logger) { try { diff --git a/SabreTools.Helper/Tools/RomTools.cs b/SabreTools.Helper/Tools/RomTools.cs index 31818adf..c1bf91f7 100644 --- a/SabreTools.Helper/Tools/RomTools.cs +++ b/SabreTools.Helper/Tools/RomTools.cs @@ -17,9 +17,9 @@ namespace SabreTools.Helper /// True if SHA-1 hashes should not be calcluated, false otherwise /// Populated RomData object if success, empty one on error /// Add read-offset for hash info - public static RomData GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0) + public static Rom GetSingleFileInfo(string input, bool noMD5 = false, bool noSHA1 = false, long offset = 0) { - RomData rom = new RomData + Rom rom = new Rom { Name = Path.GetFileName(input), Type = "rom", @@ -74,7 +74,7 @@ namespace SabreTools.Helper } catch (IOException) { - return new RomData(); + return new Rom(); } return rom; @@ -144,19 +144,19 @@ namespace SabreTools.Helper /// List of RomData objects representing the roms to be merged /// Logger object for console and/or file output /// A List of RomData objects representing the merged roms - public static List Merge(List inroms, Logger logger) + public static List Merge(List inroms, Logger logger) { // Check for null or blank roms first if (inroms == null || inroms.Count == 0) { - return new List(); + return new List(); } // Create output list - List outroms = new List(); + List outroms = new List(); // Then deduplicate them by checking to see if data matches previous saved roms - foreach (RomData rom in inroms) + foreach (Rom rom in inroms) { // If it's a nodump, add and skip if (rom.Nodump) @@ -170,11 +170,11 @@ namespace SabreTools.Helper { // Check if the rom is a duplicate DupeType dupetype = DupeType.None; - RomData savedrom = new RomData(); + Rom savedrom = new Rom(); int pos = -1; for (int i = 0; i < outroms.Count; i++) { - RomData lastrom = outroms[i]; + Rom lastrom = outroms[i]; // Get the duplicate status dupetype = GetDuplicateStatus(rom, lastrom); @@ -240,9 +240,9 @@ namespace SabreTools.Helper /// Rom to use as a base /// DAT to match against /// List of matched RomData objects - public static List GetDuplicates(RomData lastrom, DatData datdata) + public static List GetDuplicates(Rom lastrom, Dat datdata) { - List output = new List(); + List output = new List(); // Check for an empty rom list first if (datdata.Roms == null || datdata.Roms.Count == 0) @@ -251,9 +251,9 @@ namespace SabreTools.Helper } // Try to find duplicates - foreach (List roms in datdata.Roms.Values) + foreach (List roms in datdata.Roms.Values) { - foreach (RomData rom in roms) + foreach (Rom rom in roms) { if (IsDuplicate(rom, lastrom)) { @@ -271,7 +271,7 @@ namespace SabreTools.Helper /// Rom to check for duplicate status /// Rom to use as a baseline /// True if the roms are duplicates, false otherwise - public static bool IsDuplicate(RomData rom, RomData lastrom) + public static bool IsDuplicate(Rom rom, Rom lastrom) { bool dupefound = false; @@ -305,7 +305,7 @@ namespace SabreTools.Helper /// Current rom to check /// Last rom to check against /// The DupeType corresponding to the relationship between the two - public static DupeType GetDuplicateStatus(RomData rom, RomData lastrom) + public static DupeType GetDuplicateStatus(Rom rom, Rom lastrom) { DupeType output = DupeType.None; @@ -350,9 +350,9 @@ namespace SabreTools.Helper /// List of RomData objects representing the roms to be sorted /// True if files are not renamed, false otherwise /// True if it sorted correctly, false otherwise - public static bool Sort(List roms, bool norename) + public static bool Sort(List roms, bool norename) { - roms.Sort(delegate (RomData x, RomData y) + roms.Sort(delegate (Rom x, Rom y) { if (x.Metadata.SystemID == y.Metadata.SystemID) { diff --git a/SabreTools.Helper/Tools/Stats.cs b/SabreTools.Helper/Tools/Stats.cs index 3e94afc3..945ba060 100644 --- a/SabreTools.Helper/Tools/Stats.cs +++ b/SabreTools.Helper/Tools/Stats.cs @@ -47,9 +47,9 @@ namespace SabreTools.Helper { _logger.User("Beginning stat collection for '" + filename + "'"); List games = new List(); - DatData datdata = new DatData(); + Dat datdata = new Dat(); datdata = DatTools.Parse(filename, 0, 0, datdata, _logger); - SortedDictionary> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false); + SortedDictionary> newroms = DatTools.BucketByGame(datdata.Roms, false, true, _logger, false); // Output single DAT stats (if asked) if (_single) @@ -76,7 +76,7 @@ namespace SabreTools.Helper // Output total DAT stats if (!_single) { _logger.User(""); } - DatData totaldata = new DatData + Dat totaldata = new Dat { TotalSize = totalSize, RomCount = totalRom, @@ -102,7 +102,7 @@ Please check the log folder if the stats scrolled offscreen"); /// Logger object for file and console writing /// True if numbers should be recalculated for the DAT, false otherwise (default) /// Number of games to use, -1 means recalculate games (default) - public static void OutputStats(DatData datdata, Logger logger, bool recalculate = false, long game = -1) + public static void OutputStats(Dat datdata, Logger logger, bool recalculate = false, long game = -1) { if (recalculate) { @@ -116,9 +116,9 @@ Please check the log folder if the stats scrolled offscreen"); datdata.NodumpCount = 0; // Loop through and add - foreach (List roms in datdata.Roms.Values) + foreach (List roms in datdata.Roms.Values) { - foreach (RomData rom in roms) + foreach (Rom rom in roms) { datdata.RomCount += (rom.Type == "rom" ? 1 : 0); datdata.DiskCount += (rom.Type == "disk" ? 1 : 0); @@ -131,7 +131,7 @@ Please check the log folder if the stats scrolled offscreen"); } } - SortedDictionary> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger); + SortedDictionary> newroms = DatTools.BucketByGame(datdata.Roms, false, true, logger); logger.User(@" Uncompressed size: " + Style.GetBytesReadable(datdata.TotalSize) + @" Games found: " + (game == -1 ? newroms.Count : game) + @" Roms found: " + datdata.RomCount + @" diff --git a/SabreTools.Helper/Tools/Style.cs b/SabreTools.Helper/Tools/Style.cs index 324039ea..e823431b 100644 --- a/SabreTools.Helper/Tools/Style.cs +++ b/SabreTools.Helper/Tools/Style.cs @@ -144,7 +144,7 @@ namespace SabreTools.Helper /// Output directory /// DAT information /// String representing the proper name - public static string CreateOutfileName(string outDir, DatData datdata) + public static string CreateOutfileName(string outDir, Dat datdata) { // Double check the outdir for the end delim if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString())) diff --git a/SabreTools.sln b/SabreTools.sln index ec5faffa..fa7bfab3 100644 --- a/SabreTools.sln +++ b/SabreTools.sln @@ -58,6 +58,14 @@ Global {7668FFA4-19AF-4F5D-8463-C7EF5B080FA4}.Release|Any CPU.Build.0 = Release|Any CPU {7668FFA4-19AF-4F5D-8463-C7EF5B080FA4}.Release|x64.ActiveCfg = Release|x64 {7668FFA4-19AF-4F5D-8463-C7EF5B080FA4}.Release|x64.Build.0 = Release|x64 + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Debug|x64.ActiveCfg = Debug|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Debug|x64.Build.0 = Debug|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Release|Any CPU.Build.0 = Release|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Release|x64.ActiveCfg = Release|Any CPU + {9B0BF92E-C347-4DB5-BF60-C34AEACD3FB5}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SabreTools/DATFromDir.cs b/SabreTools/DATFromDir.cs index 8501bbf1..b2f75f73 100644 --- a/SabreTools/DATFromDir.cs +++ b/SabreTools/DATFromDir.cs @@ -18,7 +18,7 @@ namespace SabreTools // User specified inputs private List _inputs; - private DatData _datdata; + private Dat _datdata; private bool _noMD5; private bool _noSHA1; private bool _bare; @@ -40,7 +40,7 @@ namespace SabreTools /// True if GZIP archives should be treated as files, false otherwise> /// Logger object for console and file output /// Name of the directory to create a temp folder in (blank is current directory) - public DATFromDir(List inputs, DatData datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles, bool enableGzip, string tempDir, Logger logger) + public DATFromDir(List inputs, Dat datdata, bool noMD5, bool noSHA1, bool bare, bool archivesAsFiles, bool enableGzip, string tempDir, Logger logger) { _inputs = inputs; _datdata = datdata; @@ -152,7 +152,7 @@ namespace SabreTools if (!items) { string actualroot = item.Remove(0, basePathBackup.Length); - RomData rom = new RomData + Rom rom = new Rom { Name = "null", Game = (_datdata.Type == "SuperDAT" ? @@ -173,7 +173,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); _datdata.Roms.Add(key, temp); } @@ -185,7 +185,7 @@ namespace SabreTools if (Directory.EnumerateFiles(subdir, "*", SearchOption.AllDirectories).Count() == 0) { string actualroot = subdir.Remove(0, basePathBackup.Length); - RomData rom = new RomData + Rom rom = new Rom { Name = "null", Game = (_datdata.Type == "SuperDAT" ? @@ -206,7 +206,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); _datdata.Roms.Add(key, temp); } @@ -226,11 +226,11 @@ namespace SabreTools // Now output any empties to the stream (if not in Romba mode) if (!_datdata.Romba) { - foreach (List roms in _datdata.Roms.Values) + foreach (List roms in _datdata.Roms.Values) { for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; // If we're in a mode that doesn't allow for actual empty folders, add the blank info if (_datdata.OutputFormat != OutputFormat.SabreDat && _datdata.OutputFormat != OutputFormat.MissFile) @@ -269,7 +269,7 @@ namespace SabreTools // If we had roms but not blanks (and not in Romba mode), create an artifical rom for the purposes of outputting if (lastparent != null && _datdata.Roms.Count == 0) { - _datdata.Roms.Add("temp", new List()); + _datdata.Roms.Add("temp", new List()); } } @@ -297,7 +297,7 @@ namespace SabreTools // Special case for if we are in Romba mode (all names are supposed to be SHA-1 hashes) if (_datdata.Romba) { - RomData rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger); + Rom rom = ArchiveTools.GetTorrentGZFileInfo(item, _logger); // If the rom is valid, write it out if (rom.Name != null) @@ -360,10 +360,10 @@ namespace SabreTools /// DatData object with output information /// Last known parent game name /// New last known parent game name - private string ProcessFile(string item, StreamWriter sw, string basepath, string parent, DatData datdata, string lastparent) + private string ProcessFile(string item, StreamWriter sw, string basepath, string parent, Dat datdata, string lastparent) { _logger.Log(Path.GetFileName(item) + " treated like a file"); - RomData rom = RomTools.GetSingleFileInfo(item, _noMD5, _noSHA1); + Rom rom = RomTools.GetSingleFileInfo(item, _noMD5, _noSHA1); try { diff --git a/SabreTools/ImportExport/GenerateTwo.cs b/SabreTools/ImportExport/GenerateTwo.cs index 6fb1da44..f255eeca 100644 --- a/SabreTools/ImportExport/GenerateTwo.cs +++ b/SabreTools/ImportExport/GenerateTwo.cs @@ -144,7 +144,7 @@ namespace SabreTools } // Create the output DatData object - DatData datdata = new DatData + Dat datdata = new Dat { FileName = description, Name = name, @@ -188,11 +188,11 @@ namespace SabreTools List keys = datdata.Roms.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List newroms = datdata.Roms[key]; + List temp = new List(); + List newroms = datdata.Roms[key]; for (int i = 0; i < newroms.Count; i++) { - RomData rom = newroms[i]; + Rom rom = newroms[i]; // In the case that the RomData is incomplete, skip it if (rom.Name == null || rom.Game == null) diff --git a/SabreTools/MergeDiff.cs b/SabreTools/MergeDiff.cs index 5202f28f..872dd489 100644 --- a/SabreTools/MergeDiff.cs +++ b/SabreTools/MergeDiff.cs @@ -114,8 +114,8 @@ namespace SabreTools } // Create a dictionary of all ROMs from the input DATs - DatData userData; - List datHeaders = PopulateUserData(out userData); + Dat userData; + List datHeaders = PopulateUserData(out userData); // Modify the Dictionary if necessary and output the results if (_diff && !_cascade) @@ -141,14 +141,14 @@ namespace SabreTools /// /// Output user DatData object to output /// List of DatData objects representing headers - private List PopulateUserData(out DatData userData) + private List PopulateUserData(out Dat userData) { - List datHeaders = new List(); + List datHeaders = new List(); int i = 0; - userData = new DatData + userData = new Dat { - Roms = new Dictionary>(), + Roms = new Dictionary>(), MergeRoms = _dedup, }; foreach (string input in _inputs) @@ -160,7 +160,7 @@ namespace SabreTools // If we are in inplace mode or redirecting output, save the DAT data if (_inplace || !String.IsNullOrEmpty(_outdir)) { - datHeaders.Add(new DatData + datHeaders.Add(new Dat { FileName = userData.FileName, Name = userData.Name, @@ -208,14 +208,14 @@ namespace SabreTools /// /// Main DatData to draw information from /// Dat headers used optionally - private void DiffNoCascade(DatData userData, List datHeaders) + private void DiffNoCascade(Dat userData, List datHeaders) { DateTime start = DateTime.Now; _logger.User("Initializing all output DATs"); // Don't have External dupes string post = " (No Duplicates)"; - DatData outerDiffData = new DatData + Dat outerDiffData = new Dat { FileName = _desc + post, Name = _name + post, @@ -227,11 +227,11 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; // Have External dupes post = " (Duplicates)"; - DatData dupeData = new DatData + Dat dupeData = new Dat { FileName = _desc + post, Name = _name + post, @@ -243,17 +243,17 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; // Create a list of DatData objects representing individual output files - List outDats = new List(); + List outDats = new List(); // Loop through each of the inputs and get or create a new DatData object for (int j = 0; j < _inputs.Count; j++) { post = " (" + Path.GetFileNameWithoutExtension(_inputs[j].Split('¬')[0]) + " Only)"; - DatData diffData = new DatData + Dat diffData = new Dat { FileName = _desc + post, Name = _name + post, @@ -265,7 +265,7 @@ namespace SabreTools ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = (_old ? OutputFormat.ClrMamePro : OutputFormat.Xml), MergeRoms = _dedup, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; outDats.Add(diffData); } @@ -277,11 +277,11 @@ namespace SabreTools List keys = userData.Roms.Keys.ToList(); foreach (string key in keys) { - List roms = RomTools.Merge(userData.Roms[key], _logger); + List roms = RomTools.Merge(userData.Roms[key], _logger); if (roms != null && roms.Count > 0) { - foreach (RomData rom in roms) + foreach (Rom rom in roms) { // No duplicates if (rom.Dupe < DupeType.ExternalHash) @@ -293,13 +293,13 @@ namespace SabreTools } else { - List tl = new List(); + List tl = new List(); tl.Add(rom); outDats[rom.Metadata.SystemID].Roms.Add(key, tl); } // Merged no-duplicates DAT - RomData newrom = rom; + Rom newrom = rom; newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")"; if (outerDiffData.Roms.ContainsKey(key)) @@ -308,7 +308,7 @@ namespace SabreTools } else { - List tl = new List(); + List tl = new List(); tl.Add(rom); outerDiffData.Roms.Add(key, tl); } @@ -317,7 +317,7 @@ namespace SabreTools // Duplicates only if (rom.Dupe >= DupeType.ExternalHash) { - RomData newrom = rom; + Rom newrom = rom; newrom.Game += " (" + Path.GetFileNameWithoutExtension(_inputs[newrom.Metadata.SystemID].Split('¬')[0]) + ")"; if (dupeData.Roms.ContainsKey(key)) @@ -326,7 +326,7 @@ namespace SabreTools } else { - List tl = new List(); + List tl = new List(); tl.Add(rom); dupeData.Roms.Add(key, tl); } @@ -366,12 +366,12 @@ namespace SabreTools /// /// Main DatData to draw information from /// Dat headers used optionally - private void DiffCascade(DatData userData, List datHeaders) + private void DiffCascade(Dat userData, List datHeaders) { string post = ""; // Create a list of DatData objects representing output files - List outDats = new List(); + List outDats = new List(); // Loop through each of the inputs and get or create a new DatData object DateTime start = DateTime.Now; @@ -379,7 +379,7 @@ namespace SabreTools for (int j = 0; j < _inputs.Count; j++) { post = " (" + Path.GetFileNameWithoutExtension(_inputs[j].Split('¬')[0]) + " Only)"; - DatData diffData; + Dat diffData; // If we're in inplace mode, take the appropriate DatData object already stored if (_inplace || !String.IsNullOrEmpty(_outdir)) @@ -388,7 +388,7 @@ namespace SabreTools } else { - diffData = new DatData + diffData = new Dat { FileName = _desc + post, Name = _name + post, @@ -403,7 +403,7 @@ namespace SabreTools }; } - diffData.Roms = new Dictionary>(); + diffData.Roms = new Dictionary>(); outDats.Add(diffData); } _logger.User("Initializing complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); @@ -414,11 +414,11 @@ namespace SabreTools List keys = userData.Roms.Keys.ToList(); foreach (string key in keys) { - List roms = RomTools.Merge(userData.Roms[key], _logger); + List roms = RomTools.Merge(userData.Roms[key], _logger); if (roms != null && roms.Count > 0) { - foreach (RomData rom in roms) + foreach (Rom rom in roms) { if (outDats[rom.Metadata.SystemID].Roms.ContainsKey(key)) { @@ -426,7 +426,7 @@ namespace SabreTools } else { - List tl = new List(); + List tl = new List(); tl.Add(rom); outDats[rom.Metadata.SystemID].Roms.Add(key, tl); } @@ -465,7 +465,7 @@ namespace SabreTools /// /// Main DatData to draw information from /// Dat headers used optionally - private void MergeNoDiff(DatData userData, List datHeaders) + private void MergeNoDiff(Dat userData, List datHeaders) { // If we're in SuperDAT mode, prefix all games with their respective DATs if (_superdat) @@ -473,10 +473,10 @@ namespace SabreTools List keys = userData.Roms.Keys.ToList(); foreach (string key in keys) { - List newroms = new List(); - foreach (RomData rom in userData.Roms[key]) + List newroms = new List(); + foreach (Rom rom in userData.Roms[key]) { - RomData newrom = rom; + Rom newrom = rom; string filename = _inputs[newrom.Metadata.SystemID].Split('¬')[0]; string rootpath = _inputs[newrom.Metadata.SystemID].Split('¬')[1]; diff --git a/SabreTools/OfflineMerge.cs b/SabreTools/OfflineMerge.cs index f381bba8..d9321f1c 100644 --- a/SabreTools/OfflineMerge.cs +++ b/SabreTools/OfflineMerge.cs @@ -57,17 +57,17 @@ namespace SabreTools { // First get the combination Dictionary of currentAllMerged and currentNewMerged _logger.User("Adding Current and New Merged DATs to the dictionary"); - DatData completeDats = new DatData(); + Dat completeDats = new Dat(); completeDats = DatTools.Parse(_currentAllMerged, 0, 0, completeDats, _logger); completeDats = DatTools.Parse(_currentNewMerged, 0, 0, completeDats, _logger); // Now get Net New output dictionary [(currentNewMerged)-(currentAllMerged)] _logger.User("Creating and populating Net New dictionary"); - Dictionary> netNew = new Dictionary>(); + Dictionary> netNew = new Dictionary>(); foreach (string key in completeDats.Roms.Keys) { - List templist = RomTools.Merge(completeDats.Roms[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(completeDats.Roms[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged) { @@ -77,7 +77,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); netNew.Add(key, temp); } @@ -87,11 +87,11 @@ namespace SabreTools // Now create the Unneeded dictionary [(currentAllMerged)-(currentNewMerged)] _logger.User("Creating and populating Uneeded dictionary"); - Dictionary> unneeded = new Dictionary>(); + Dictionary> unneeded = new Dictionary>(); foreach (string key in completeDats.Roms.Keys) { - List templist = RomTools.Merge(completeDats.Roms[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(completeDats.Roms[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged) { @@ -101,7 +101,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); unneeded.Add(key, temp); } @@ -111,7 +111,7 @@ namespace SabreTools // Now create the New Missing dictionary [(Net New)+(currentMissingMerged-(Unneeded))] _logger.User("Creating and populating New Missing dictionary"); - DatData midMissing = new DatData(); + Dat midMissing = new Dat(); midMissing = DatTools.Parse(_currentMissingMerged, 0, 0, midMissing, _logger); foreach (string key in unneeded.Keys) { @@ -124,11 +124,11 @@ namespace SabreTools midMissing.Roms.Add(key, unneeded[key]); } } - Dictionary> newMissing = new Dictionary>(); + Dictionary> newMissing = new Dictionary>(); foreach (string key in midMissing.Roms.Keys) { - List templist = RomTools.Merge(midMissing.Roms[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(midMissing.Roms[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentMissingMerged) { @@ -138,7 +138,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); newMissing.Add(key, temp); } @@ -159,7 +159,7 @@ namespace SabreTools // Now create the Have dictionary [(currentNewMerged)-(c)] _logger.User("Creating and populating Have dictionary"); - Dictionary> midHave = new Dictionary>(); + Dictionary> midHave = new Dictionary>(); foreach (string key in newMissing.Keys) { if (midHave.ContainsKey(key)) @@ -175,7 +175,7 @@ namespace SabreTools { if (midHave.ContainsKey(key)) { - foreach (RomData rom in completeDats.Roms[key]) + foreach (Rom rom in completeDats.Roms[key]) { if (rom.Metadata.System == _currentNewMerged) { @@ -185,8 +185,8 @@ namespace SabreTools } else { - List roms = new List(); - foreach (RomData rom in completeDats.Roms[key]) + List roms = new List(); + foreach (Rom rom in completeDats.Roms[key]) { if (rom.Metadata.System == _currentNewMerged) { @@ -196,11 +196,11 @@ namespace SabreTools midHave.Add(key, roms); } } - Dictionary> have = new Dictionary>(); + Dictionary> have = new Dictionary>(); foreach (string key in midHave.Keys) { - List templist = RomTools.Merge(midHave[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(midHave[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged) { @@ -210,7 +210,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); have.Add(key, temp); } @@ -225,11 +225,11 @@ namespace SabreTools List keys = netNew.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = netNew[key]; + List temp = new List(); + List roms = netNew[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -243,11 +243,11 @@ namespace SabreTools keys = unneeded.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = unneeded[key]; + List temp = new List(); + List roms = unneeded[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -261,11 +261,11 @@ namespace SabreTools keys = newMissing.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = newMissing[key]; + List temp = new List(); + List roms = newMissing[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -279,11 +279,11 @@ namespace SabreTools keys = have.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = have[key]; + List temp = new List(); + List roms = have[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -295,7 +295,7 @@ namespace SabreTools } // Finally, output all of the files - DatData netNewData = new DatData + Dat netNewData = new Dat { Name = "Net New", Description = "Net New", @@ -308,7 +308,7 @@ namespace SabreTools MergeRoms = true, Roms = netNew, }; - DatData unneededData = new DatData + Dat unneededData = new Dat { Name = "Unneeded", Description = "Unneeded", @@ -321,7 +321,7 @@ namespace SabreTools MergeRoms = true, Roms = unneeded, }; - DatData newMissingData = new DatData + Dat newMissingData = new Dat { Name = "New Missing", Description = "New Missing", @@ -334,7 +334,7 @@ namespace SabreTools MergeRoms = true, Roms = newMissing, }; - DatData haveData = new DatData + Dat haveData = new Dat { Name = "Have", Description = "Have", @@ -361,14 +361,14 @@ namespace SabreTools { // Now create the Have dictionary [(currentAllMerged)-(currentMissingMerged)] _logger.User("Creating and populating Have dictionary"); - DatData midHave = new DatData(); + Dat midHave = new Dat(); midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger); midHave = DatTools.Parse(_currentAllMerged, 0, 0, midHave, _logger); - Dictionary> have = new Dictionary>(); + Dictionary> have = new Dictionary>(); foreach (string key in midHave.Roms.Keys) { - List templist = RomTools.Merge(midHave.Roms[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(midHave.Roms[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentAllMerged) { @@ -378,7 +378,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); have.Add(key, temp); } @@ -393,11 +393,11 @@ namespace SabreTools List keys = have.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = have[key]; + List temp = new List(); + List roms = have[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -408,7 +408,7 @@ namespace SabreTools } } - DatData haveData = new DatData + Dat haveData = new Dat { Name = "Have", Description = "Have", @@ -431,14 +431,14 @@ namespace SabreTools { // Now create the Have dictionary [(currentNewMerged)-(currentMissingMerged)] _logger.User("Creating and populating Have dictionary"); - DatData midHave = new DatData(); + Dat midHave = new Dat(); midHave = DatTools.Parse(_currentMissingMerged, 0, 0, midHave, _logger); midHave = DatTools.Parse(_currentNewMerged, 0, 0, midHave, _logger); - Dictionary> have = new Dictionary>(); + Dictionary> have = new Dictionary>(); foreach (string key in midHave.Roms.Keys) { - List templist = RomTools.Merge(midHave.Roms[key], _logger); - foreach (RomData rom in templist) + List templist = RomTools.Merge(midHave.Roms[key], _logger); + foreach (Rom rom in templist) { if (rom.Dupe == DupeType.None && rom.Metadata.System == _currentNewMerged) { @@ -448,7 +448,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); have.Add(key, temp); } @@ -463,11 +463,11 @@ namespace SabreTools List keys = have.Keys.ToList(); foreach (string key in keys) { - List temp = new List(); - List roms = have[key]; + List temp = new List(); + List roms = have[key]; for (int i = 0; i < roms.Count; i++) { - RomData rom = roms[i]; + Rom rom = roms[i]; rom.Size = Constants.SizeZero; rom.CRC = Constants.CRCZero; rom.MD5 = Constants.MD5Zero; @@ -478,7 +478,7 @@ namespace SabreTools } } - DatData haveData = new DatData + Dat haveData = new Dat { Name = "Have", Description = "Have", diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 54568b7f..3805a232 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -228,7 +228,7 @@ namespace SabreTools repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext); // Populate the DatData object - DatData userInputDat = new DatData + Dat userInputDat = new Dat { FileName = filename, Name = name, @@ -329,7 +329,7 @@ namespace SabreTools string tempDir) { // Create a new DATFromDir object and process the inputs - DatData datdata = new DatData + Dat datdata = new Dat { FileName = description, Name = name, @@ -342,7 +342,7 @@ namespace SabreTools OutputFormat = (old ? OutputFormat.ClrMamePro : OutputFormat.Xml), Romba = romba, Type = (superdat ? "SuperDAT" : ""), - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; DATFromDir dfd = new DATFromDir(inputs, datdata, noMD5, noSHA1, bare, archivesAsFiles, enableGzip, tempDir, _logger); bool success = dfd.Start(); diff --git a/SabreTools/Split.cs b/SabreTools/Split.cs index ae5ad9ea..aaef021f 100644 --- a/SabreTools/Split.cs +++ b/SabreTools/Split.cs @@ -130,12 +130,12 @@ namespace SabreTools // Get the file data to be split OutputFormat outputFormat = DatTools.GetOutputFormat(filename); - DatData datdata = new DatData(); + Dat datdata = new Dat(); datdata = DatTools.Parse(filename, 0, 0, datdata, _logger, true); // Create each of the respective output DATs _logger.User("Creating and populating new DATs"); - DatData nodump = new DatData + Dat nodump = new Dat { FileName = datdata.FileName + " (Nodump)", Name = datdata.Name + " (Nodump)", @@ -155,9 +155,9 @@ namespace SabreTools ForcePacking = datdata.ForcePacking, OutputFormat = outputFormat, MergeRoms = datdata.MergeRoms, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; - DatData sha1 = new DatData + Dat sha1 = new Dat { FileName = datdata.FileName + " (SHA-1)", Name = datdata.Name + " (SHA-1)", @@ -177,9 +177,9 @@ namespace SabreTools ForcePacking = datdata.ForcePacking, OutputFormat = outputFormat, MergeRoms = datdata.MergeRoms, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; - DatData md5 = new DatData + Dat md5 = new Dat { FileName = datdata.FileName + " (MD5)", Name = datdata.Name + " (MD5)", @@ -199,9 +199,9 @@ namespace SabreTools ForcePacking = datdata.ForcePacking, OutputFormat = outputFormat, MergeRoms = datdata.MergeRoms, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; - DatData crc = new DatData + Dat crc = new Dat { FileName = datdata.FileName + " (CRC)", Name = datdata.Name + " (CRC)", @@ -221,15 +221,15 @@ namespace SabreTools ForcePacking = datdata.ForcePacking, OutputFormat = outputFormat, MergeRoms = datdata.MergeRoms, - Roms = new Dictionary>(), + Roms = new Dictionary>(), }; // Now populate each of the DAT objects in turn List keys = datdata.Roms.Keys.ToList(); foreach (string key in keys) { - List roms = datdata.Roms[key]; - foreach (RomData rom in roms) + List roms = datdata.Roms[key]; + foreach (Rom rom in roms) { // If the file is a nodump if (rom.Nodump) @@ -240,7 +240,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); nodump.Roms.Add(key, temp); } @@ -254,7 +254,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); sha1.Roms.Add(key, temp); } @@ -268,7 +268,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); md5.Roms.Add(key, temp); } @@ -282,7 +282,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); crc.Roms.Add(key, temp); } @@ -333,12 +333,12 @@ namespace SabreTools private bool SplitByExt(string filename, string basepath) { // Load the current DAT to be processed - DatData datdata = new DatData(); + Dat datdata = new Dat(); datdata = DatTools.Parse(filename, 0, 0, datdata, _logger); // Set all of the appropriate outputs for each of the subsets OutputFormat outputFormat = DatTools.GetOutputFormat(filename); - DatData datdataA = new DatData + Dat datdataA = new Dat { FileName = datdata.FileName + " (" + String.Join(",", _extA) + ")", Name = datdata.Name + " (" + String.Join(",", _extA) + ")", @@ -351,10 +351,10 @@ namespace SabreTools Homepage = datdata.Homepage, Url = datdata.Url, Comment = datdata.Comment, - Roms = new Dictionary>(), + Roms = new Dictionary>(), OutputFormat = outputFormat, }; - DatData datdataB = new DatData + Dat datdataB = new Dat { FileName = datdata.FileName + " (" + String.Join(",", _extB) + ")", Name = datdata.Name + " (" + String.Join(",", _extB) + ")", @@ -367,7 +367,7 @@ namespace SabreTools Homepage = datdata.Homepage, Url = datdata.Url, Comment = datdata.Comment, - Roms = new Dictionary>(), + Roms = new Dictionary>(), OutputFormat = outputFormat, }; @@ -380,7 +380,7 @@ namespace SabreTools // Now separate the roms accordingly foreach (string key in datdata.Roms.Keys) { - foreach (RomData rom in datdata.Roms[key]) + foreach (Rom rom in datdata.Roms[key]) { if (_extA.Contains(Path.GetExtension(rom.Name.ToUpperInvariant()))) { @@ -390,7 +390,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdataA.Roms.Add(key, temp); } @@ -403,7 +403,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdataB.Roms.Add(key, temp); } @@ -416,7 +416,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdataA.Roms.Add(key, temp); } @@ -426,7 +426,7 @@ namespace SabreTools } else { - List temp = new List(); + List temp = new List(); temp.Add(rom); datdataB.Roms.Add(key, temp); } diff --git a/SabreTools/TrimMerge.cs b/SabreTools/TrimMerge.cs index e517c09a..41e92ebf 100644 --- a/SabreTools/TrimMerge.cs +++ b/SabreTools/TrimMerge.cs @@ -82,7 +82,7 @@ namespace SabreTools /// True if roms are to be renamed private void ProcessDAT(string filename, string path, bool rename) { - DatData datdata = new DatData + Dat datdata = new Dat { ForcePacking = (_forceunpack ? ForcePacking.Unzip : ForcePacking.None), OutputFormat = DatTools.GetOutputFormat(filename), @@ -93,10 +93,10 @@ namespace SabreTools List keys = datdata.Roms.Keys.ToList(); foreach (string key in keys) { - List newroms = new List(); - foreach (RomData rom in datdata.Roms[key]) + List newroms = new List(); + foreach (Rom rom in datdata.Roms[key]) { - RomData newrom = rom; + Rom newrom = rom; // If we are in single game mode, rename all games if (rename) diff --git a/SimpleSort/SimpleSort.cs b/SimpleSort/SimpleSort.cs index 975dda9a..0299dfcc 100644 --- a/SimpleSort/SimpleSort.cs +++ b/SimpleSort/SimpleSort.cs @@ -10,7 +10,7 @@ namespace SabreTools public class SimpleSort { // Private instance variables - private DatData _datdata; + private Dat _datdata; private List _inputs; private string _outdir; private string _tempdir; @@ -34,7 +34,7 @@ namespace SabreTools /// Integer representing the archive handling level for RAR /// Integer representing the archive handling level for Zip /// Logger object for file and console output - public SimpleSort(DatData datdata, List inputs, string outdir, string tempdir, + public SimpleSort(Dat datdata, List inputs, string outdir, string tempdir, bool externalScan, int sevenzip, int gz, int rar, int zip, Logger logger) { _datdata = datdata; @@ -239,7 +239,7 @@ namespace SabreTools bool externalScan, int sevenzip, int gz, int rar, int zip, Logger logger) { // Add all of the input DATs into one huge internal DAT - DatData datdata = new DatData(); + Dat datdata = new Dat(); foreach (string datfile in datfiles) { datdata = DatTools.Parse(datfile, 0, 0, datdata, logger); @@ -359,7 +359,7 @@ namespace SabreTools // Hash and match the external files if (shouldscan) { - RomData rom = RomTools.GetSingleFileInfo(input); + Rom rom = RomTools.GetSingleFileInfo(input); // If we have a blank RomData, it's an error if (rom.Name == null) @@ -368,9 +368,9 @@ namespace SabreTools } // Try to find the matches to the file that was found - List foundroms = RomTools.GetDuplicates(rom, _datdata); + List foundroms = RomTools.GetDuplicates(rom, _datdata); _logger.User("File '" + input + "' had " + foundroms.Count + " matches in the DAT!"); - foreach (RomData found in foundroms) + foreach (Rom found in foundroms) { _logger.Log("Matched name: " + found.Name); ArchiveTools.WriteToArchive(input, _outdir, found); @@ -384,7 +384,7 @@ namespace SabreTools string newinput = input + ".new"; _logger.Log("Creating unheadered file: '" + newinput + "'"); Output.RemoveBytesFromFile(input, newinput, hs, 0); - RomData drom = RomTools.GetSingleFileInfo(newinput); + Rom drom = RomTools.GetSingleFileInfo(newinput); // If we have a blank RomData, it's an error if (drom.Name == null) @@ -393,16 +393,16 @@ namespace SabreTools } // Try to find the matches to the file that was found - List founddroms = RomTools.GetDuplicates(drom, _datdata); + List founddroms = RomTools.GetDuplicates(drom, _datdata); _logger.User("File '" + newinput + "' had " + founddroms.Count + " matches in the DAT!"); - foreach (RomData found in founddroms) + foreach (Rom found in founddroms) { // First output the headerless rom _logger.Log("Matched name: " + found.Name); ArchiveTools.WriteToArchive(newinput, _outdir, found); // Then output the headered rom (renamed) - RomData newfound = found; + Rom newfound = found; newfound.Name = Path.GetFileNameWithoutExtension(newfound.Name) + " (" + rom.CRC + ")" + Path.GetExtension(newfound.Name); _logger.Log("Matched name: " + newfound.Name); @@ -425,18 +425,18 @@ namespace SabreTools if (_externalScan) { _logger.Log("Beginning quick scan of contents from '" + input + "'"); - List internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger); + List internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger); _logger.Log(internalRomData.Count + " entries found in '" + input + "'"); // If the list is populated, then the file was a filled archive if (internalRomData.Count > 0) { - foreach (RomData rom in internalRomData) + foreach (Rom rom in internalRomData) { // Try to find the matches to the file that was found - List foundroms = RomTools.GetDuplicates(rom, _datdata); + List foundroms = RomTools.GetDuplicates(rom, _datdata); _logger.User("File '" + rom.Name + "' had " + foundroms.Count + " matches in the DAT!"); - foreach (RomData found in foundroms) + foreach (Rom found in foundroms) { _logger.Log("Matched name: " + found.Name); string newinput = ArchiveTools.ExtractSingleItemFromArchive(input, rom.Name, _tempdir, _logger); @@ -530,7 +530,7 @@ namespace SabreTools */ // Sort the input set(s) by game - SortedDictionary> sortedByGame = DatTools.BucketByGame(_datdata.Roms, false, true, _logger); + SortedDictionary> sortedByGame = DatTools.BucketByGame(_datdata.Roms, false, true, _logger); // Assuming archived sets, move all toplevel folders to temp foreach (string directory in Directory.EnumerateDirectories(_outdir, "*", SearchOption.TopDirectoryOnly)) @@ -554,7 +554,7 @@ namespace SabreTools // Finally, if it's an archive and exists properly, we check the insides else { - List roms = new List(); + List roms = new List(); // If we are in quickscan, get the list of roms that way if (_externalScan) @@ -582,9 +582,9 @@ namespace SabreTools We have to check if it's an exact duplicate or a hash-duplicate Which is better: traversing the "should have" list or the "do have" list? */ - List fromDat = sortedByGame[Path.GetFileNameWithoutExtension(archive)]; - List toRemove = new List(); - foreach (RomData rom in roms) + List fromDat = sortedByGame[Path.GetFileNameWithoutExtension(archive)]; + List toRemove = new List(); + foreach (Rom rom in roms) { // If it's not in at all or needs renaming, mark for removal if (!fromDat.Contains(rom))