[SabreTools, DatFile, DatHeader] StripHash no longer needed

This commit is contained in:
Matt Nadareski
2018-03-22 17:00:45 -07:00
parent 5449ae6015
commit fe37c4f27e
4 changed files with 5 additions and 111 deletions

View File

@@ -351,19 +351,6 @@ namespace SabreTools.Library.DatFiles
_datHeader.DedupeRoms = value; _datHeader.DedupeRoms = value;
} }
} }
public Hash StripHash
{
get
{
EnsureDatHeader();
return _datHeader.StripHash;
}
set
{
EnsureDatHeader();
_datHeader.StripHash = value;
}
}
public SortedBy SortedBy public SortedBy SortedBy
{ {
get { return _sortedBy; } get { return _sortedBy; }
@@ -1356,7 +1343,6 @@ namespace SabreTools.Library.DatFiles
KeepEmptyGames = this.KeepEmptyGames, KeepEmptyGames = this.KeepEmptyGames,
SceneDateStrip = this.SceneDateStrip, SceneDateStrip = this.SceneDateStrip,
DedupeRoms = this.DedupeRoms, DedupeRoms = this.DedupeRoms,
StripHash = this.StripHash,
Prefix = this.Prefix, Prefix = this.Prefix,
Postfix = this.Postfix, Postfix = this.Postfix,
AddExtension = this.AddExtension, AddExtension = this.AddExtension,
@@ -1431,7 +1417,6 @@ namespace SabreTools.Library.DatFiles
KeepEmptyGames = this.KeepEmptyGames, KeepEmptyGames = this.KeepEmptyGames,
SceneDateStrip = this.SceneDateStrip, SceneDateStrip = this.SceneDateStrip,
DedupeRoms = this.DedupeRoms, DedupeRoms = this.DedupeRoms,
StripHash = this.StripHash,
Prefix = this.Prefix, Prefix = this.Prefix,
Postfix = this.Postfix, Postfix = this.Postfix,
AddExtension = this.AddExtension, AddExtension = this.AddExtension,
@@ -2182,81 +2167,6 @@ namespace SabreTools.Library.DatFiles
} }
} }
/// <summary>
/// Strip the given hash types from the DAT
/// </summary>
private void StripHashesFromItems()
{
// Output the logging statement
Globals.Logger.User("Stripping requested hashes");
// Now process all of the roms
List<string> keys = Keys;
Parallel.ForEach(keys, Globals.ParallelOptions, key =>
{
List<DatItem> items = this[key];
for (int j = 0; j < items.Count; j++)
{
DatItem item = items[j];
if (item.Type == ItemType.Rom)
{
Rom rom = (Rom)item;
if ((StripHash & Hash.MD5) != 0)
{
rom.MD5 = null;
}
if ((StripHash & Hash.SHA1) != 0)
{
rom.SHA1 = null;
}
if ((StripHash & Hash.SHA256) != 0)
{
rom.SHA256 = null;
}
if ((StripHash & Hash.SHA384) != 0)
{
rom.SHA384 = null;
}
if ((StripHash & Hash.SHA512) != 0)
{
rom.SHA512 = null;
}
items[j] = rom;
}
else if (item.Type == ItemType.Disk)
{
Disk disk = (Disk)item;
if ((StripHash & Hash.MD5) != 0)
{
disk.MD5 = null;
}
if ((StripHash & Hash.SHA1) != 0)
{
disk.SHA1 = null;
}
if ((StripHash & Hash.SHA256) != 0)
{
disk.SHA256 = null;
}
if ((StripHash & Hash.SHA384) != 0)
{
disk.SHA384 = null;
}
if ((StripHash & Hash.SHA512) != 0)
{
disk.SHA512 = null;
}
items[j] = disk;
}
}
Remove(key);
AddRange(key, items);
});
}
/// <summary> /// <summary>
/// Strip the dates from the beginning of scene-style set names /// Strip the dates from the beginning of scene-style set names
/// </summary> /// </summary>
@@ -5332,12 +5242,6 @@ namespace SabreTools.Library.DatFiles
// Output the number of items we're going to be writing // Output the number of items we're going to be writing
Globals.Logger.User("A total of {0} items will be written out to '{1}'", Count, FileName); Globals.Logger.User("A total of {0} items will be written out to '{1}'", Count, FileName);
// If we are removing hashes, do that now
if (StripHash != 0x0)
{
StripHashesFromItems();
}
// If we are removing scene dates, do that now // If we are removing scene dates, do that now
if (SceneDateStrip) if (SceneDateStrip)
{ {

View File

@@ -169,11 +169,6 @@ namespace SabreTools.Library.DatFiles
get { return _dedupeRoms; } get { return _dedupeRoms; }
set { _dedupeRoms = value; } set { _dedupeRoms = value; }
} }
public Hash StripHash
{
get { return _stripHash; }
set { _stripHash = value; }
}
// Data specific to the Miss DAT type // Data specific to the Miss DAT type
public bool UseRomName public bool UseRomName

View File

@@ -884,7 +884,7 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all MD5 hashes from the output file(s)."); longDescription: "By default, all available hashes will be written out to the DAT. This will remove all MD5 hashes from the output file(s).");
} }
} } // TODO: Remove
private static Feature _removeSha1Flag private static Feature _removeSha1Flag
{ {
get get
@@ -896,7 +896,7 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-1 hashes from the output file(s)."); longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-1 hashes from the output file(s).");
} }
} } // TODO: Remove
private static Feature _removeSha256Flag private static Feature _removeSha256Flag
{ {
get get
@@ -908,7 +908,7 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-256 hashes from the output file(s)."); longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-256 hashes from the output file(s).");
} }
} } // TODO: Remove
private static Feature _removeSha384Flag private static Feature _removeSha384Flag
{ {
get get
@@ -920,7 +920,7 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-384 hashes from the output file(s)."); longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-384 hashes from the output file(s).");
} }
} } // TODO: Remove
private static Feature _removeSha512Flag private static Feature _removeSha512Flag
{ {
get get
@@ -932,7 +932,7 @@ namespace SabreTools
FeatureType.Flag, FeatureType.Flag,
longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-512 hashes from the output file(s)."); longDescription: "By default, all available hashes will be written out to the DAT. This will remove all SHA-512 hashes from the output file(s).");
} }
} } // TODO: Remove
private static Feature _removeUnicodeFlag private static Feature _removeUnicodeFlag
{ {
get get

View File

@@ -454,23 +454,18 @@ namespace SabreTools
datHeader.RemoveExtension = true; datHeader.RemoveExtension = true;
break; break;
case "remove-md5": case "remove-md5":
datHeader.StripHash |= Hash.MD5;
datHeader.ExcludeFields[(int)Field.MD5] = true; datHeader.ExcludeFields[(int)Field.MD5] = true;
break; break;
case "remove-sha1": case "remove-sha1":
datHeader.StripHash |= Hash.SHA1;
datHeader.ExcludeFields[(int)Field.SHA1] = true; datHeader.ExcludeFields[(int)Field.SHA1] = true;
break; break;
case "remove-sha256": case "remove-sha256":
datHeader.StripHash |= Hash.SHA256;
datHeader.ExcludeFields[(int)Field.SHA256] = true; datHeader.ExcludeFields[(int)Field.SHA256] = true;
break; break;
case "remove-sha384": case "remove-sha384":
datHeader.StripHash |= Hash.SHA384;
datHeader.ExcludeFields[(int)Field.SHA384] = true; datHeader.ExcludeFields[(int)Field.SHA384] = true;
break; break;
case "remove-sha512": case "remove-sha512":
datHeader.StripHash |= Hash.SHA512;
datHeader.ExcludeFields[(int)Field.SHA512] = true; datHeader.ExcludeFields[(int)Field.SHA512] = true;
break; break;
case "remove-unicode": case "remove-unicode":