diff --git a/RombaSharp/Partials/RombaSharp.Helpers.cs b/RombaSharp/Partials/RombaSharp.Helpers.cs index 7b23b66c..fd2eceac 100644 --- a/RombaSharp/Partials/RombaSharp.Helpers.cs +++ b/RombaSharp/Partials/RombaSharp.Helpers.cs @@ -405,7 +405,7 @@ namespace RombaSharp // First get a list of SHA-1's from the input DATs DatFile datroot = new DatFile { Type = "SuperDAT", }; datroot.PopulateFromDir(_dats, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, false, false, false, _tmpdir, false, null, 4, _logger); - datroot.BucketBySHA1(false, _logger, false); + datroot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); // Create a List of dat hashes in the database (SHA-1) List databaseDats = new List(); @@ -435,7 +435,7 @@ namespace RombaSharp unneeded.Add(hash); } } - datroot.BucketByGame(false, true, _logger, false); + datroot.BucketBy(SortedBy.Game, false /* mergeroms */, _logger, output: false, norename: true); _logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); @@ -619,7 +619,7 @@ namespace RombaSharp // Now rescan the depot itself DatFile depot = new DatFile(); depot.PopulateFromDir(depotname, Hash.SHA256 & Hash.SHA384 & Hash.SHA512, false, false, true, false, false, _tmpdir, false, null, _workers, _logger); - depot.BucketBySHA1(false, _logger, false); + depot.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); // Set the base queries to use string crcquery = "INSERT OR IGNORE INTO crc (crc) VALUES"; diff --git a/SabreTools.Helper/Dats/DatItem.cs b/SabreTools.Helper/Dats/DatItem.cs index 604d281c..d0749907 100644 --- a/SabreTools.Helper/Dats/DatItem.cs +++ b/SabreTools.Helper/Dats/DatItem.cs @@ -345,12 +345,12 @@ namespace SabreTools.Helper.Dats if (_itemType == ItemType.Rom) { key = ((Rom)this).SHA512; - datdata.BucketBySHA512(false, logger, false); + datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false); } else { key = ((Disk)this).SHA512; - datdata.BucketBySHA512(false, logger, false); + datdata.BucketBy(SortedBy.SHA512, false /* mergeroms */, logger, output: false); } } @@ -362,12 +362,12 @@ namespace SabreTools.Helper.Dats if (_itemType == ItemType.Rom) { key = ((Rom)this).SHA384; - datdata.BucketBySHA384(false, logger, false); + datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false); } else { key = ((Disk)this).SHA384; - datdata.BucketBySHA384(false, logger, false); + datdata.BucketBy(SortedBy.SHA384, false /* mergeroms */, logger, output: false); } } @@ -379,12 +379,12 @@ namespace SabreTools.Helper.Dats if (_itemType == ItemType.Rom) { key = ((Rom)this).SHA256; - datdata.BucketBySHA256(false, logger, false); + datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false); } else { key = ((Disk)this).SHA256; - datdata.BucketBySHA256(false, logger, false); + datdata.BucketBy(SortedBy.SHA256, false /* mergeroms */, logger, output: false); } } @@ -396,12 +396,12 @@ namespace SabreTools.Helper.Dats if (_itemType == ItemType.Rom) { key = ((Rom)this).SHA1; - datdata.BucketBySHA1(false, logger, false); + datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); } else { key = ((Disk)this).SHA1; - datdata.BucketBySHA1(false, logger, false); + datdata.BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); } } @@ -413,12 +413,12 @@ namespace SabreTools.Helper.Dats if (_itemType == ItemType.Rom) { key = ((Rom)this).MD5; - datdata.BucketByMD5(false, logger, false); + datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false); } else { key = ((Disk)this).MD5; - datdata.BucketByMD5(false, logger, false); + datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false); } } @@ -426,21 +426,21 @@ namespace SabreTools.Helper.Dats else if (_itemType == ItemType.Disk) { key = ((Disk)this).MD5; - datdata.BucketByMD5(false, logger, false); + datdata.BucketBy(SortedBy.MD5, false /* mergeroms */, logger, output: false); } // If we've gotten here and we have a Rom, sort by CRC else if (_itemType == ItemType.Rom) { key = ((Rom)this).CRC; - datdata.BucketByCRC(false, logger, false); + datdata.BucketBy(SortedBy.CRC, false /* mergeroms */, logger, output: false); } // Otherwise, we use -1 as the key else { key = "-1"; - datdata.BucketBySize(false, logger, false); + datdata.BucketBy(SortedBy.Size, false /* mergeroms */, logger, output: false); } return key; diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs b/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs index fd23f2cc..878ca2c5 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using System.Web; using SabreTools.Helper.Data; @@ -14,570 +15,132 @@ namespace SabreTools.Helper.Dats #region Bucketing [MODULAR DONE] /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by CRC + /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by a user-defined method /// + /// SortedBy enum representing how to sort the individual items /// True if roms should be deduped, false otherwise /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketByCRC(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.CRC) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.CRC; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by CRC"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).CRC : Constants.CRCZero); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by Game - /// - /// True if roms should be deduped, false otherwise + /// True if the key should be lowercased (default), false otherwise /// True if games should only be compared on game and file name, false if system and source are counted - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - /// True if the game should be lowercased (default), false otherwise - public void BucketByGame(bool mergeroms, bool norename, Logger logger, bool output = true, bool lower = true) + public void BucketBy(SortedBy bucketBy, bool mergeroms, Logger logger, bool output = true, bool lower = true, bool norename = true) { // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.Game) + if (_sortedBy == bucketBy) { return; } // Set the sorted type - _sortedBy = SortedBy.Game; + _sortedBy = bucketBy; SortedDictionary> sortable = new SortedDictionary>(); long count = 0; - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by game"); + logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by " + bucketBy); - // Process each all of the roms + // First do the initial sort of all of the roms List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) + Parallel.ForEach(keys, + key => { - roms = DatItem.Merge(roms, logger); - } + List roms = this[key]; - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (norename ? "" - : rom.SystemID.ToString().PadLeft(10, '0') - + "-" - + rom.SourceID.ToString().PadLeft(10, '0') + "-") - + (String.IsNullOrEmpty(rom.Machine.Name) - ? "Default" - : rom.Machine.Name); - if (lower) + // If we're merging the roms, do so + if (mergeroms) { - newkey = newkey.ToLowerInvariant(); + roms = DatItem.Merge(roms, logger); } - newkey = HttpUtility.HtmlEncode(newkey); - - if (!sortable.ContainsKey(newkey)) + // Now add each of the roms to their respective games + foreach (DatItem rom in roms) { - sortable.Add(newkey, new List()); + count++; + string newkey = ""; + + switch (bucketBy) + { + case SortedBy.CRC: + newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).CRC : Constants.CRCZero); + break; + case SortedBy.Game: + newkey = (norename ? "" + : rom.SystemID.ToString().PadLeft(10, '0') + + "-" + + rom.SourceID.ToString().PadLeft(10, '0') + "-") + + (String.IsNullOrEmpty(rom.Machine.Name) + ? "Default" + : rom.Machine.Name); + if (lower) + { + newkey = newkey.ToLowerInvariant(); + } + + newkey = HttpUtility.HtmlEncode(newkey); + break; + case SortedBy.MD5: + newkey = (rom.Type == ItemType.Rom + ? ((Rom)rom).MD5 + : (rom.Type == ItemType.Disk + ? ((Disk)rom).MD5 + : Constants.MD5Zero)); + break; + case SortedBy.SHA1: + newkey = (rom.Type == ItemType.Rom + ? ((Rom)rom).SHA1 + : (rom.Type == ItemType.Disk + ? ((Disk)rom).SHA1 + : Constants.SHA1Zero)); + break; + case SortedBy.SHA256: + newkey = (rom.Type == ItemType.Rom + ? ((Rom)rom).SHA256 + : (rom.Type == ItemType.Disk + ? ((Disk)rom).SHA256 + : Constants.SHA256Zero)); + break; + case SortedBy.SHA384: + newkey = (rom.Type == ItemType.Rom + ? ((Rom)rom).SHA384 + : (rom.Type == ItemType.Disk + ? ((Disk)rom).SHA384 + : Constants.SHA384Zero)); + break; + case SortedBy.SHA512: + newkey = (rom.Type == ItemType.Rom + ? ((Rom)rom).SHA512 + : (rom.Type == ItemType.Disk + ? ((Disk)rom).SHA512 + : Constants.SHA512Zero)); + break; + } + + if (!sortable.ContainsKey(newkey)) + { + sortable.Add(newkey, new List()); + } + sortable[newkey].Add(rom); } + }); - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists + // Now go through and sort all of the individual lists keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, norename); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by MD5 - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketByMD5(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.MD5) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.MD5; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by MD5"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom - ? ((Rom)rom).MD5 - : (rom.Type == ItemType.Disk - ? ((Disk)rom).MD5 - : Constants.MD5Zero)); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) + Parallel.ForEach(keys, + key => { List sortedlist = sortable[key]; DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } + + lock (sortable) + { + sortable[key] = sortedlist; + } + }); // Output the count if told to if (output) { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA1 - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketBySHA1(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.SHA1) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.SHA1; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-1"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom - ? ((Rom)rom).SHA1 - : (rom.Type == ItemType.Disk - ? ((Disk)rom).SHA1 - : Constants.SHA1Zero)); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA256 - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketBySHA256(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.SHA256) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.SHA256; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-256"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom - ? ((Rom)rom).SHA256 - : (rom.Type == ItemType.Disk - ? ((Disk)rom).SHA256 - : Constants.SHA256Zero)); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA384 - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketBySHA384(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.SHA384) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.SHA384; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-384"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom - ? ((Rom)rom).SHA384 - : (rom.Type == ItemType.Disk - ? ((Disk)rom).SHA384 - : Constants.SHA384Zero)); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by SHA512 - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketBySHA512(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.SHA512) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.SHA512; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by SHA-512"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom - ? ((Rom)rom).SHA512 - : (rom.Type == ItemType.Disk - ? ((Disk)rom).SHA512 - : Constants.SHA512Zero)); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); - } - - // Now assign the dictionary back - _files = sortable; - } - - /// - /// Take the arbitrarily sorted Files Dictionary and convert to one sorted by Size - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void BucketBySize(bool mergeroms, Logger logger, bool output = true) - { - // If we already have the right sorting, trust it - if (_sortedBy == SortedBy.Size) - { - return; - } - - // Set the sorted type - _sortedBy = SortedBy.Size; - - SortedDictionary> sortable = new SortedDictionary>(); - long count = 0; - - logger.User("Organizing " + (mergeroms ? "and merging " : "") + "roms by size"); - - // Process each all of the roms - List keys = Keys.ToList(); - foreach (string key in keys) - { - List roms = this[key]; - - // If we're merging the roms, do so - if (mergeroms) - { - roms = DatItem.Merge(roms, logger); - } - - // Now add each of the roms to their respective games - foreach (DatItem rom in roms) - { - count++; - string newkey = (rom.Type == ItemType.Rom ? ((Rom)rom).Size.ToString() : "-1"); - - if (!sortable.ContainsKey(newkey)) - { - sortable.Add(newkey, new List()); - } - sortable[newkey].Add(rom); - } - } - - // Now go through and sort all of the lists - keys = sortable.Keys.ToList(); - foreach (string key in keys) - { - List sortedlist = sortable[key]; - DatItem.Sort(ref sortedlist, false); - sortable[key] = sortedlist; - } - - // Output the count if told to - if (output) - { - logger.User("A total of " + count + " file hashes will be written out to file"); + logger.User("A total of " + count + " items will be written out to file"); } // Now assign the dictionary back @@ -599,7 +162,7 @@ namespace SabreTools.Helper.Dats logger.User("Creating fully non-merged sets from the DAT"); // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); + BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true); _sortedBy = SortedBy.Default; // Now we want to loop through all of the games and set the correct information @@ -627,7 +190,7 @@ namespace SabreTools.Helper.Dats logger.User("Creating merged sets from the DAT"); // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); + BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true); _sortedBy = SortedBy.Default; // Now we want to loop through all of the games and set the correct information @@ -651,7 +214,7 @@ namespace SabreTools.Helper.Dats logger.User("Creating non-merged sets from the DAT"); // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); + BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true); _sortedBy = SortedBy.Default; // Now we want to loop through all of the games and set the correct information @@ -675,7 +238,7 @@ namespace SabreTools.Helper.Dats logger.User("Creating split sets from the DAT"); // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); + BucketBy(SortedBy.Game, mergeroms, logger, output: output, norename: true); _sortedBy = SortedBy.Default; // Now we want to loop through all of the games and set the correct information diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs index 015459b6..3f132340 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs @@ -145,7 +145,7 @@ namespace SabreTools.Helper.Dats } // Now that we have a list of depots, we want to sort the input DAT by SHA-1 - BucketBySHA1(false, logger, output: false); + BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); // Then we want to loop through each of the hashes and see if we can rebuild List hashes = Keys.ToList(); @@ -830,7 +830,7 @@ namespace SabreTools.Helper.Dats } // Now that we have a list of depots, we want to sort the input DAT by SHA-1 - BucketBySHA1(false, logger, output: false); + BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); // Then we want to loop through each of the hashes and see if we can rebuild List hashes = Keys.ToList(); @@ -941,7 +941,7 @@ namespace SabreTools.Helper.Dats if (hashOnly) { // First we need to sort by hash to get duplicates - BucketBySHA1(true, logger, output: false); + BucketBy(SortedBy.SHA1, false /* mergeroms */, logger, output: false); // Then follow the same tactics as before foreach (string key in Keys) diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Splitters.cs b/SabreTools.Helper/Dats/Partials/DatFile.Splitters.cs index 55055f90..17c8893e 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Splitters.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Splitters.cs @@ -322,7 +322,7 @@ namespace SabreTools.Helper.Dats basepath = (basepath.EndsWith(Path.DirectorySeparatorChar.ToString()) ? basepath : basepath + Path.DirectorySeparatorChar); // First, organize by games so that we can do the right thing - BucketByGame(false, true, logger, output: false, lower: false); + BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, lower: false, norename: true); // Create a temporary DAT to add things to DatFile tempDat = new DatFile(this); diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs index 1178f235..af0bf6ff 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Statistics.cs @@ -116,7 +116,7 @@ namespace SabreTools.Helper.Dats RecalculateStats(); } - BucketByGame(false, true, logger, false); + BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, norename: true); if (TotalSize < 0) { TotalSize = Int64.MaxValue + TotalSize; @@ -387,7 +387,7 @@ namespace SabreTools.Helper.Dats List games = new List(); DatFile datdata = new DatFile(); datdata.Parse(filename.Item1, 0, 0, logger); - datdata.BucketByGame(false, true, logger, false); + datdata.BucketBy(SortedBy.Game, false /* mergeroms */, logger, output: false, norename: true); // Output single DAT stats (if asked) logger.User("Adding stats for file '" + filename.Item1 + "'\n", false); diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Writers.cs b/SabreTools.Helper/Dats/Partials/DatFile.Writers.cs index e6b3219d..653de619 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Writers.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Writers.cs @@ -109,7 +109,7 @@ namespace SabreTools.Helper.Dats } // Bucket roms by game name and optionally dedupe - BucketByGame(MergeRoms, norename, logger); + BucketBy(SortedBy.Game, MergeRoms, logger, norename: norename); // Filter the DAT by 1G1R rules, if we're supposed to // TODO: Create 1G1R logic before write