diff --git a/SabreTools.DatFiles/DatFile.cs b/SabreTools.DatFiles/DatFile.cs
index e474b633..f95839bc 100644
--- a/SabreTools.DatFiles/DatFile.cs
+++ b/SabreTools.DatFiles/DatFile.cs
@@ -277,7 +277,7 @@ namespace SabreTools.DatFiles
}
// Get the key and add the file
- key = item.GetKey(Field.Machine_Name);
+ key = item.GetKey(ItemKey.Machine);
Items.Add(key, item);
return key;
diff --git a/SabreTools.DatFiles/ItemDictionary.cs b/SabreTools.DatFiles/ItemDictionary.cs
index 1c953640..c8466a1b 100644
--- a/SabreTools.DatFiles/ItemDictionary.cs
+++ b/SabreTools.DatFiles/ItemDictionary.cs
@@ -24,7 +24,7 @@ namespace SabreTools.DatFiles
///
/// Determine the bucketing key for all items
///
- private Field bucketedBy;
+ private ItemKey bucketedBy;
///
/// Determine merging type for all items
@@ -616,10 +616,10 @@ namespace SabreTools.DatFiles
}
///
- /// Override the internal Field value
+ /// Override the internal ItemKey value
///
///
- public void SetBucketedBy(Field newBucket)
+ public void SetBucketedBy(ItemKey newBucket)
{
bucketedBy = newBucket;
}
@@ -930,7 +930,7 @@ namespace SabreTools.DatFiles
///
public ItemDictionary()
{
- bucketedBy = Field.NULL;
+ bucketedBy = ItemKey.NULL;
mergedBy = DedupeType.None;
items = new ConcurrentDictionary>();
logger = new Logger(this);
@@ -943,11 +943,11 @@ namespace SabreTools.DatFiles
///
/// Take the arbitrarily bucketed Files Dictionary and convert to one bucketed by a user-defined method
///
- /// Field enum representing how to bucket the individual items
+ /// ItemKey enum representing how to bucket the individual items
/// Dedupe type that should be used
/// 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
- public void BucketBy(Field bucketBy, DedupeType dedupeType, bool lower = true, bool norename = true)
+ public void BucketBy(ItemKey bucketBy, DedupeType dedupeType, bool lower = true, bool norename = true)
{
// If we have a situation where there's no dictionary or no keys at all, we skip
if (items == null || items.Count == 0)
@@ -1013,7 +1013,7 @@ namespace SabreTools.DatFiles
DatItem.Sort(ref sortedlist, false);
// If we're merging the roms, do so
- if (dedupeType == DedupeType.Full || (dedupeType == DedupeType.Game && bucketBy == Field.Machine_Name))
+ if (dedupeType == DedupeType.Full || (dedupeType == DedupeType.Game && bucketBy == ItemKey.Machine))
sortedlist = DatItem.Merge(sortedlist);
// Add the list back to the dictionary
@@ -1208,31 +1208,31 @@ namespace SabreTools.DatFiles
///
/// Get the highest-order Field value that represents the statistics
///
- private Field GetBestAvailable()
+ private ItemKey GetBestAvailable()
{
// If all items are supposed to have a SHA-512, we bucket by that
if (DiskCount + MediaCount + RomCount - NodumpCount == SHA512Count)
- return Field.DatItem_SHA512;
+ return ItemKey.SHA512;
// If all items are supposed to have a SHA-384, we bucket by that
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA384Count)
- return Field.DatItem_SHA384;
+ return ItemKey.SHA384;
// If all items are supposed to have a SHA-256, we bucket by that
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA256Count)
- return Field.DatItem_SHA256;
+ return ItemKey.SHA256;
// If all items are supposed to have a SHA-1, we bucket by that
else if (DiskCount + MediaCount + RomCount - NodumpCount == SHA1Count)
- return Field.DatItem_SHA1;
+ return ItemKey.SHA1;
// If all items are supposed to have a MD5, we bucket by that
else if (DiskCount + MediaCount + RomCount - NodumpCount == MD5Count)
- return Field.DatItem_MD5;
+ return ItemKey.MD5;
// Otherwise, we bucket by CRC
else
- return Field.DatItem_CRC;
+ return ItemKey.CRC;
}
///
diff --git a/SabreTools.DatItems/DatItem.cs b/SabreTools.DatItems/DatItem.cs
index a3f41eeb..f73aac78 100644
--- a/SabreTools.DatItems/DatItem.cs
+++ b/SabreTools.DatItems/DatItem.cs
@@ -429,12 +429,12 @@ namespace SabreTools.DatItems
///
/// Get the dictionary key that should be used for a given item and bucketing type
///
- /// Field value representing what key to get
+ /// ItemKey value representing what key to get
/// 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
/// String representing the key to be used for the DatItem
/// TODO: What other fields can we reasonably allow bucketing on?
- public virtual string GetKey(Field bucketedBy, bool lower = true, bool norename = true)
+ public virtual string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
{
// Set the output key as the default blank string
string key = string.Empty;
@@ -442,11 +442,11 @@ namespace SabreTools.DatItems
// Now determine what the key should be based on the bucketedBy value
switch (bucketedBy)
{
- case Field.DatItem_CRC:
+ case ItemKey.CRC:
key = Constants.CRCZero;
break;
- case Field.Machine_Name:
+ case ItemKey.Machine:
key = (norename ? string.Empty
: Source.Index.ToString().PadLeft(10, '0')
+ "-")
@@ -461,27 +461,27 @@ namespace SabreTools.DatItems
break;
- case Field.DatItem_MD5:
+ case ItemKey.MD5:
key = Constants.MD5Zero;
break;
- case Field.DatItem_SHA1:
+ case ItemKey.SHA1:
key = Constants.SHA1Zero;
break;
- case Field.DatItem_SHA256:
+ case ItemKey.SHA256:
key = Constants.SHA256Zero;
break;
- case Field.DatItem_SHA384:
+ case ItemKey.SHA384:
key = Constants.SHA384Zero;
break;
- case Field.DatItem_SHA512:
+ case ItemKey.SHA512:
key = Constants.SHA512Zero;
break;
- case Field.DatItem_SpamSum:
+ case ItemKey.SpamSum:
key = Constants.SpamSumZero;
break;
}
diff --git a/SabreTools.DatItems/Disk.cs b/SabreTools.DatItems/Disk.cs
index cd6a02c9..7a0c9109 100644
--- a/SabreTools.DatItems/Disk.cs
+++ b/SabreTools.DatItems/Disk.cs
@@ -366,14 +366,8 @@ namespace SabreTools.DatItems
#region Sorting and Merging
- ///
- /// Get the dictionary key that should be used for a given item and bucketing type
- ///
- /// Field enum representing what key to get
- /// 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
- /// String representing the key to be used for the DatItem
- public override string GetKey(Field bucketedBy, bool lower = true, bool norename = true)
+ ///
+ public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
{
// Set the output key as the default blank string
string key = string.Empty;
@@ -381,11 +375,11 @@ namespace SabreTools.DatItems
// Now determine what the key should be based on the bucketedBy value
switch (bucketedBy)
{
- case Field.DatItem_MD5:
+ case ItemKey.MD5:
key = MD5;
break;
- case Field.DatItem_SHA1:
+ case ItemKey.SHA1:
key = SHA1;
break;
diff --git a/SabreTools.DatItems/Enums.cs b/SabreTools.DatItems/Enums.cs
index 2d8b150c..a6e782d0 100644
--- a/SabreTools.DatItems/Enums.cs
+++ b/SabreTools.DatItems/Enums.cs
@@ -16,4 +16,22 @@ namespace SabreTools.DatItems
Internal = 1 << 2,
External = 1 << 3,
}
+
+ ///
+ /// A subset of fields that can be used as keys
+ ///
+ public enum ItemKey
+ {
+ NULL = 0,
+
+ Machine,
+
+ CRC,
+ MD5,
+ SHA1,
+ SHA256,
+ SHA384,
+ SHA512,
+ SpamSum,
+ }
}
\ No newline at end of file
diff --git a/SabreTools.DatItems/Media.cs b/SabreTools.DatItems/Media.cs
index 6e166cf9..700f61b1 100644
--- a/SabreTools.DatItems/Media.cs
+++ b/SabreTools.DatItems/Media.cs
@@ -289,14 +289,8 @@ namespace SabreTools.DatItems
#region Sorting and Merging
- ///
- /// Get the dictionary key that should be used for a given item and bucketing type
- ///
- /// Field enum representing what key to get
- /// 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
- /// String representing the key to be used for the DatItem
- public override string GetKey(Field bucketedBy, bool lower = true, bool norename = true)
+ ///
+ public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
{
// Set the output key as the default blank string
string key = string.Empty;
@@ -304,19 +298,19 @@ namespace SabreTools.DatItems
// Now determine what the key should be based on the bucketedBy value
switch (bucketedBy)
{
- case Field.DatItem_MD5:
+ case ItemKey.MD5:
key = MD5;
break;
- case Field.DatItem_SHA1:
+ case ItemKey.SHA1:
key = SHA1;
break;
- case Field.DatItem_SHA256:
+ case ItemKey.SHA256:
key = SHA256;
break;
- case Field.DatItem_SpamSum:
+ case ItemKey.SpamSum:
key = SpamSum;
break;
diff --git a/SabreTools.DatItems/Rom.cs b/SabreTools.DatItems/Rom.cs
index 4c0ec57c..d74b4737 100644
--- a/SabreTools.DatItems/Rom.cs
+++ b/SabreTools.DatItems/Rom.cs
@@ -625,14 +625,8 @@ namespace SabreTools.DatItems
#region Sorting and Merging
- ///
- /// Get the dictionary key that should be used for a given item and bucketing type
- ///
- /// Field enum representing what key to get
- /// 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
- /// String representing the key to be used for the DatItem
- public override string GetKey(Field bucketedBy, bool lower = true, bool norename = true)
+ ///
+ public override string GetKey(ItemKey bucketedBy, bool lower = true, bool norename = true)
{
// Set the output key as the default blank string
string key = string.Empty;
@@ -640,31 +634,31 @@ namespace SabreTools.DatItems
// Now determine what the key should be based on the bucketedBy value
switch (bucketedBy)
{
- case Field.DatItem_CRC:
+ case ItemKey.CRC:
key = CRC;
break;
- case Field.DatItem_MD5:
+ case ItemKey.MD5:
key = MD5;
break;
- case Field.DatItem_SHA1:
+ case ItemKey.SHA1:
key = SHA1;
break;
- case Field.DatItem_SHA256:
+ case ItemKey.SHA256:
key = SHA256;
break;
- case Field.DatItem_SHA384:
+ case ItemKey.SHA384:
key = SHA384;
break;
- case Field.DatItem_SHA512:
+ case ItemKey.SHA512:
key = SHA512;
break;
- case Field.DatItem_SpamSum:
+ case ItemKey.SpamSum:
key = SpamSum;
break;
diff --git a/SabreTools.DatTools/DatFromDir.cs b/SabreTools.DatTools/DatFromDir.cs
index cbd2c497..addb77f8 100644
--- a/SabreTools.DatTools/DatFromDir.cs
+++ b/SabreTools.DatTools/DatFromDir.cs
@@ -337,7 +337,7 @@ namespace SabreTools.DatTools
SetDatItemInfo(datFile, datItem, item, parent, basepath);
// Add the file information to the DAT
- string key = datItem.GetKey(Field.DatItem_CRC);
+ string key = datItem.GetKey(ItemKey.CRC);
datFile.Items.Add(key, datItem);
logger.Verbose($"File added: {datItem.GetName() ?? string.Empty}");