[ALL] Switch naming of Hash, add new variants

This commit is contained in:
Matt Nadareski
2017-02-26 22:41:17 -08:00
parent 0c3d89dbde
commit 8f5a66c41d
6 changed files with 42 additions and 43 deletions

View File

@@ -244,11 +244,14 @@ namespace SabreTools.Helper.Data
/// Determine what hashes to strip from the DAT /// Determine what hashes to strip from the DAT
/// </summary> /// </summary>
[Flags] [Flags]
public enum StripHash public enum Hash
{ {
MD5 = 0x01, CRC = 0x0001,
SHA1 = 0x02, MD5 = 0x0002,
SHA256 = 0x04, SHA1 = 0x0004,
SHA256 = 0x0008,
SHA384 = 0x0010,
SHA512 = 0x0020,
} }
#endregion #endregion

View File

@@ -30,7 +30,7 @@ namespace SabreTools.Helper.Dats
private DatFormat _datFormat; private DatFormat _datFormat;
private bool _excludeOf; private bool _excludeOf;
private bool _mergeRoms; private bool _mergeRoms;
private StripHash _stripHash; private Hash _stripHash;
private SortedDictionary<string, List<DatItem>> _files = new SortedDictionary<string, List<DatItem>>(); private SortedDictionary<string, List<DatItem>> _files = new SortedDictionary<string, List<DatItem>>();
private SortedBy _sortedBy; private SortedBy _sortedBy;
@@ -161,7 +161,7 @@ namespace SabreTools.Helper.Dats
get { return _mergeRoms; } get { return _mergeRoms; }
set { _mergeRoms = value; } set { _mergeRoms = value; }
} }
public StripHash StripHash public Hash StripHash
{ {
get { return _stripHash; } get { return _stripHash; }
set { _stripHash = value; } set { _stripHash = value; }

View File

@@ -12,6 +12,8 @@ namespace SabreTools.Helper.Dats
protected string _md5; protected string _md5;
protected string _sha1; protected string _sha1;
protected string _sha256; protected string _sha256;
protected string _sha384;
protected string _sha512;
protected ItemStatus _itemStatus; protected ItemStatus _itemStatus;
#endregion #endregion
@@ -34,6 +36,16 @@ namespace SabreTools.Helper.Dats
get { return _sha256; } get { return _sha256; }
set { _sha256 = value; } set { _sha256 = value; }
} }
public string SHA384
{
get { return _sha384; }
set { _sha384 = value; }
}
public string SHA512
{
get { return _sha512; }
set { _sha512 = value; }
}
public ItemStatus ItemStatus public ItemStatus ItemStatus
{ {
get { return _itemStatus; } get { return _itemStatus; }

View File

@@ -441,32 +441,7 @@ namespace SabreTools.Helper.Dats
private void StripHashesFromItems(Logger logger) private void StripHashesFromItems(Logger logger)
{ {
// Output the logging statement // Output the logging statement
string set = ""; logger.User("Stripping requested hashes");
switch ((int)StripHash)
{
case 0x01:
set = "MD5";
break;
case 0x02:
set = "SHA-1";
break;
case 0x03:
set = "MD5 and SHA-1";
break;
case 0x04:
set = "SHA-256";
break;
case 0x05:
set = "MD5 and SHA-256";
break;
case 0x06:
set = "SHA-1 and SHA-256";
break;
case 0x07:
set = "MD5, SHA-1, and SHA-256";
break;
}
logger.User("Stripping " + set + " hashes");
// Now process all of the roms // Now process all of the roms
List<string> keys = Keys.ToList(); List<string> keys = Keys.ToList();
@@ -479,35 +454,44 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom) if (item.Type == ItemType.Rom)
{ {
Rom rom = (Rom)item; Rom rom = (Rom)item;
if ((StripHash & StripHash.MD5) != 0) if ((StripHash & Hash.MD5) != 0)
{ {
rom.MD5 = null; rom.MD5 = null;
} }
if ((StripHash & StripHash.SHA1) != 0) if ((StripHash & Hash.SHA1) != 0)
{ {
rom.SHA1 = null; rom.SHA1 = null;
} }
if ((StripHash & StripHash.SHA256) != 0) if ((StripHash & Hash.SHA256) != 0)
{ {
rom.SHA256 = null; rom.SHA256 = null;
} }
items[j] = rom; items[j] = rom;
} }
else if (item.Type == ItemType.Disk) else if (item.Type == ItemType.Disk)
{ {
Disk disk = (Disk)item; Disk disk = (Disk)item;
if ((StripHash & StripHash.MD5) != 0) if ((StripHash & Hash.MD5) != 0)
{ {
disk.MD5 = null; disk.MD5 = null;
} }
if ((StripHash & StripHash.SHA1) != 0) if ((StripHash & Hash.SHA1) != 0)
{ {
disk.SHA1 = null; disk.SHA1 = null;
} }
if ((StripHash & StripHash.SHA256) != 0) if ((StripHash & Hash.SHA256) != 0)
{ {
disk.SHA256 = null; disk.SHA256 = null;
} }
if ((StripHash & Hash.SHA384) != 0)
{
disk.SHA384 = null;
}
if ((StripHash & Hash.SHA512) != 0)
{
disk.SHA512 = null;
}
items[j] = disk; items[j] = disk;
} }
} }

View File

@@ -530,7 +530,7 @@ namespace SabreTools
bool clean, bool clean,
bool descAsName, bool descAsName,
bool dedup, bool dedup,
StripHash stripHash, Hash stripHash,
/* Multithreading info */ /* Multithreading info */
int maxDegreeOfParallelism) int maxDegreeOfParallelism)

View File

@@ -125,7 +125,7 @@ namespace SabreTools
OutputFormat outputFormat = OutputFormat.Folder; OutputFormat outputFormat = OutputFormat.Folder;
SplitType splitType = SplitType.None; SplitType splitType = SplitType.None;
StatDatFormat statDatFormat = 0x0; StatDatFormat statDatFormat = 0x0;
StripHash stripHash = 0x0; Hash stripHash = 0x0;
// User inputs // User inputs
int gz = 2, int gz = 2,
@@ -490,7 +490,7 @@ namespace SabreTools
break; break;
case "-rmd5": case "-rmd5":
case "--rem-md5": case "--rem-md5":
stripHash |= StripHash.MD5; stripHash |= Hash.MD5;
break; break;
case "-rme": case "-rme":
case "--rem-ext": case "--rem-ext":
@@ -502,11 +502,11 @@ namespace SabreTools
break; break;
case "-rsha1": case "-rsha1":
case "--rem-sha1": case "--rem-sha1":
stripHash |= StripHash.SHA1; stripHash |= Hash.SHA1;
break; break;
case "-rsha256": case "-rsha256":
case "--rem-sha256": case "--rem-sha256":
stripHash |= StripHash.SHA256; stripHash |= Hash.SHA256;
break; break;
case "-run": case "-run":
case "--runnable": case "--runnable":