diff --git a/SabreTools.Helper/Tools/DatTools.cs b/SabreTools.Helper/Tools/DatTools.cs
index 2017d054..c2ea1876 100644
--- a/SabreTools.Helper/Tools/DatTools.cs
+++ b/SabreTools.Helper/Tools/DatTools.cs
@@ -1429,6 +1429,22 @@ namespace SabreTools.Helper
return datdata;
}
+ ///
+ /// Take an arbitrarily ordered List and return a Dictionary sorted by Game
+ ///
+ /// Input unsorted list
+ /// True if roms should be deduped, 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
+ /// SortedDictionary bucketed by game name
+ public static SortedDictionary> BucketByGame(List list, bool mergeroms, bool norename, Logger logger, bool output = true)
+ {
+ Dictionary> dict = new Dictionary>();
+ dict.Add("key", list);
+ return BucketByGame(dict, mergeroms, norename, logger, output);
+ }
+
///
/// Take an arbitrarily bucketed Dictionary and return one sorted by Game
///
@@ -1438,7 +1454,7 @@ 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(Dictionary> 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>();
long count = 0;
@@ -1484,6 +1500,77 @@ namespace SabreTools.Helper
return sortable;
}
+ ///
+ /// Take an arbitrarily ordered List and return a Dictionary sorted by size and hash
+ ///
+ /// Input unsorted list
+ /// True if roms should be deduped, 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
+ /// SortedDictionary bucketed by size and hash
+ public static SortedDictionary> BucketByHashSize(List list, bool mergeroms, bool norename, Logger logger, bool output = true)
+ {
+ Dictionary> dict = new Dictionary>();
+ dict.Add("key", list);
+ return BucketByHashSize(dict, mergeroms, norename, logger, output);
+ }
+
+ ///
+ /// Take an arbitrarily bucketed Dictionary and return one sorted by size and hash
+ ///
+ /// Input unsorted dictionary
+ /// True if roms should be deduped, 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
+ /// SortedDictionary bucketed by size and hash
+ public static SortedDictionary> BucketByHashSize(IDictionary> dict, bool mergeroms, bool norename, Logger logger, bool output = true)
+ {
+ SortedDictionary> sortable = new SortedDictionary>();
+ long count = 0;
+
+ // If we have a null dict or an empty one, output a new dictionary
+ if (dict == null || dict.Count == 0)
+ {
+ return sortable;
+ }
+
+ // Process each all of the roms
+ foreach (List roms in dict.Values)
+ {
+ List newroms = roms;
+ if (mergeroms)
+ {
+ newroms = RomTools.Merge(newroms, logger);
+ }
+
+ foreach (RomData rom in newroms)
+ {
+ count++;
+ string key = rom.Size + "-" + rom.CRC; ;
+ if (sortable.ContainsKey(key))
+ {
+ sortable[key].Add(rom);
+ }
+ else
+ {
+ List temp = new List();
+ temp.Add(rom);
+ sortable.Add(key, temp);
+ }
+ }
+ }
+
+ // Output the count if told to
+ if (output)
+ {
+ logger.User("A total of " + count + " file hashes will be written out to file");
+ }
+
+ return sortable;
+ }
+
///
/// Convert, update, and filter a DAT file
///