[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
/// </summary>
[Flags]
public enum StripHash
public enum Hash
{
MD5 = 0x01,
SHA1 = 0x02,
SHA256 = 0x04,
CRC = 0x0001,
MD5 = 0x0002,
SHA1 = 0x0004,
SHA256 = 0x0008,
SHA384 = 0x0010,
SHA512 = 0x0020,
}
#endregion

View File

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

View File

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

View File

@@ -441,32 +441,7 @@ namespace SabreTools.Helper.Dats
private void StripHashesFromItems(Logger logger)
{
// Output the logging statement
string set = "";
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");
logger.User("Stripping requested hashes");
// Now process all of the roms
List<string> keys = Keys.ToList();
@@ -479,35 +454,44 @@ namespace SabreTools.Helper.Dats
if (item.Type == ItemType.Rom)
{
Rom rom = (Rom)item;
if ((StripHash & StripHash.MD5) != 0)
if ((StripHash & Hash.MD5) != 0)
{
rom.MD5 = null;
}
if ((StripHash & StripHash.SHA1) != 0)
if ((StripHash & Hash.SHA1) != 0)
{
rom.SHA1 = null;
}
if ((StripHash & StripHash.SHA256) != 0)
if ((StripHash & Hash.SHA256) != 0)
{
rom.SHA256 = null;
}
items[j] = rom;
}
else if (item.Type == ItemType.Disk)
{
Disk disk = (Disk)item;
if ((StripHash & StripHash.MD5) != 0)
if ((StripHash & Hash.MD5) != 0)
{
disk.MD5 = null;
}
if ((StripHash & StripHash.SHA1) != 0)
if ((StripHash & Hash.SHA1) != 0)
{
disk.SHA1 = null;
}
if ((StripHash & StripHash.SHA256) != 0)
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;
}
}

View File

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

View File

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