mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Update string check; add output path helper
This commit is contained in:
@@ -654,24 +654,24 @@ namespace SabreTools.Library.DatItems
|
||||
{
|
||||
// If all items are supposed to have a SHA-512, we sort by that
|
||||
if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA512Count
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA512))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA512))))
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA512))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA512))))
|
||||
{
|
||||
datdata.BucketBy(SortedBy.SHA512, DedupeType.None);
|
||||
}
|
||||
|
||||
// If all items are supposed to have a SHA-384, we sort by that
|
||||
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA384Count
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA384))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA384))))
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA384))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA384))))
|
||||
{
|
||||
datdata.BucketBy(SortedBy.SHA384, DedupeType.None);
|
||||
}
|
||||
|
||||
// If all items are supposed to have a SHA-256, we sort by that
|
||||
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA256Count
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA256))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA256))))
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA256))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA256))))
|
||||
{
|
||||
if (_itemType == ItemType.Rom)
|
||||
{
|
||||
@@ -687,8 +687,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// If all items are supposed to have a SHA-1, we sort by that
|
||||
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.SHA1Count
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).SHA1))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).SHA1))))
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).SHA1))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).SHA1))))
|
||||
{
|
||||
if (_itemType == ItemType.Rom)
|
||||
{
|
||||
@@ -704,8 +704,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// If all items are supposed to have an MD5, we sort by that
|
||||
else if (datdata.RomCount + datdata.DiskCount - datdata.NodumpCount == datdata.MD5Count
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrEmpty(((Rom)this).MD5))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrEmpty(((Disk)this).MD5))))
|
||||
&& ((_itemType == ItemType.Rom && !String.IsNullOrWhiteSpace(((Rom)this).MD5))
|
||||
|| (_itemType == ItemType.Disk && !String.IsNullOrWhiteSpace(((Disk)this).MD5))))
|
||||
{
|
||||
if (_itemType == ItemType.Rom)
|
||||
{
|
||||
@@ -887,22 +887,22 @@ namespace SabreTools.Library.DatItems
|
||||
if (file.Type == ItemType.Rom)
|
||||
{
|
||||
((Rom)saveditem).Size = ((Rom)saveditem).Size;
|
||||
((Rom)saveditem).CRC = (String.IsNullOrEmpty(((Rom)saveditem).CRC) && !String.IsNullOrEmpty(((Rom)file).CRC)
|
||||
((Rom)saveditem).CRC = (String.IsNullOrWhiteSpace(((Rom)saveditem).CRC) && !String.IsNullOrWhiteSpace(((Rom)file).CRC)
|
||||
? ((Rom)file).CRC
|
||||
: ((Rom)saveditem).CRC);
|
||||
((Rom)saveditem).MD5 = (String.IsNullOrEmpty(((Rom)saveditem).MD5) && !String.IsNullOrEmpty(((Rom)file).MD5)
|
||||
((Rom)saveditem).MD5 = (String.IsNullOrWhiteSpace(((Rom)saveditem).MD5) && !String.IsNullOrWhiteSpace(((Rom)file).MD5)
|
||||
? ((Rom)file).MD5
|
||||
: ((Rom)saveditem).MD5);
|
||||
((Rom)saveditem).SHA1 = (String.IsNullOrEmpty(((Rom)saveditem).SHA1) && !String.IsNullOrEmpty(((Rom)file).SHA1)
|
||||
((Rom)saveditem).SHA1 = (String.IsNullOrWhiteSpace(((Rom)saveditem).SHA1) && !String.IsNullOrWhiteSpace(((Rom)file).SHA1)
|
||||
? ((Rom)file).SHA1
|
||||
: ((Rom)saveditem).SHA1);
|
||||
}
|
||||
else
|
||||
{
|
||||
((Disk)saveditem).MD5 = (String.IsNullOrEmpty(((Disk)saveditem).MD5) && !String.IsNullOrEmpty(((Disk)file).MD5)
|
||||
((Disk)saveditem).MD5 = (String.IsNullOrWhiteSpace(((Disk)saveditem).MD5) && !String.IsNullOrWhiteSpace(((Disk)file).MD5)
|
||||
? ((Disk)file).MD5
|
||||
: ((Disk)saveditem).MD5);
|
||||
((Disk)saveditem).SHA1 = (String.IsNullOrEmpty(((Disk)saveditem).SHA1) && !String.IsNullOrEmpty(((Disk)file).SHA1)
|
||||
((Disk)saveditem).SHA1 = (String.IsNullOrWhiteSpace(((Disk)saveditem).SHA1) && !String.IsNullOrWhiteSpace(((Disk)file).SHA1)
|
||||
? ((Disk)file).SHA1
|
||||
: ((Disk)saveditem).SHA1);
|
||||
}
|
||||
@@ -997,9 +997,9 @@ namespace SabreTools.Library.DatItems
|
||||
if (datItem.Type == ItemType.Disk)
|
||||
{
|
||||
Disk disk = (Disk)datItem;
|
||||
disk.Name += "_" + (!String.IsNullOrEmpty(disk.MD5)
|
||||
disk.Name += "_" + (!String.IsNullOrWhiteSpace(disk.MD5)
|
||||
? disk.MD5
|
||||
: !String.IsNullOrEmpty(disk.SHA1)
|
||||
: !String.IsNullOrWhiteSpace(disk.SHA1)
|
||||
? disk.SHA1
|
||||
: "1");
|
||||
datItem = disk;
|
||||
@@ -1008,11 +1008,11 @@ namespace SabreTools.Library.DatItems
|
||||
else if (datItem.Type == ItemType.Rom)
|
||||
{
|
||||
Rom rom = (Rom)datItem;
|
||||
rom.Name += "_" + (!String.IsNullOrEmpty(rom.CRC)
|
||||
rom.Name += "_" + (!String.IsNullOrWhiteSpace(rom.CRC)
|
||||
? rom.CRC
|
||||
: !String.IsNullOrEmpty(rom.MD5)
|
||||
: !String.IsNullOrWhiteSpace(rom.MD5)
|
||||
? rom.MD5
|
||||
: !String.IsNullOrEmpty(rom.SHA1)
|
||||
: !String.IsNullOrWhiteSpace(rom.SHA1)
|
||||
? rom.SHA1
|
||||
: "1");
|
||||
datItem = rom;
|
||||
|
||||
@@ -27,27 +27,27 @@ namespace SabreTools.Library.DatItems
|
||||
// Disk information
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public ItemStatus ItemStatus
|
||||
@@ -145,19 +145,19 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
|
||||
// If we can determine that the disks have no non-empty hashes in common, we return false
|
||||
if ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty())
|
||||
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty())
|
||||
&& (this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()))
|
||||
if ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
else if (((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
else if (((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
@@ -35,32 +35,32 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
public string CRC
|
||||
{
|
||||
get { return _crc.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_crc); }
|
||||
get { return _crc.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_crc); }
|
||||
set { _crc = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string MD5
|
||||
{
|
||||
get { return _md5.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
get { return _md5.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_md5); }
|
||||
set { _md5 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA1
|
||||
{
|
||||
get { return _sha1.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
get { return _sha1.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha1); }
|
||||
set { _sha1 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA256
|
||||
{
|
||||
get { return _sha256.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
get { return _sha256.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha256); }
|
||||
set { _sha256 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA384
|
||||
{
|
||||
get { return _sha384.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
get { return _sha384.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha384); }
|
||||
set { _sha384 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string SHA512
|
||||
{
|
||||
get { return _sha512.IsNullOrEmpty() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
get { return _sha512.IsNullOrWhiteSpace() ? null : Utilities.ByteArrayToString(_sha512); }
|
||||
set { _sha512 = Utilities.StringToByteArray(value); }
|
||||
}
|
||||
public string Date
|
||||
@@ -212,22 +212,22 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
|
||||
// If we can determine that the roms have no non-empty hashes in common, we return false
|
||||
if ((_crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty())
|
||||
&& (this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty())
|
||||
&& (this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty())
|
||||
&& (this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty())
|
||||
&& (this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty())
|
||||
&& (this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()))
|
||||
if ((_crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace())
|
||||
&& (this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace())
|
||||
&& (this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace())
|
||||
&& (this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace())
|
||||
&& (this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace())
|
||||
&& (this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()))
|
||||
{
|
||||
dupefound = false;
|
||||
}
|
||||
else if ((this.Size == newOther.Size)
|
||||
&& ((this._crc.IsNullOrEmpty() || newOther._crc.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrEmpty() || newOther._md5.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrEmpty() || newOther._sha1.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrEmpty() || newOther._sha256.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrEmpty() || newOther._sha384.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrEmpty() || newOther._sha512.IsNullOrEmpty()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
&& ((this._crc.IsNullOrWhiteSpace() || newOther._crc.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._crc, newOther._crc))
|
||||
&& ((this._md5.IsNullOrWhiteSpace() || newOther._md5.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._md5, newOther._md5))
|
||||
&& ((this._sha1.IsNullOrWhiteSpace() || newOther._sha1.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha1, newOther._sha1))
|
||||
&& ((this._sha256.IsNullOrWhiteSpace() || newOther._sha256.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha256, newOther._sha256))
|
||||
&& ((this._sha384.IsNullOrWhiteSpace() || newOther._sha384.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha384, newOther._sha384))
|
||||
&& ((this._sha512.IsNullOrWhiteSpace() || newOther._sha512.IsNullOrWhiteSpace()) || Enumerable.SequenceEqual(this._sha512, newOther._sha512)))
|
||||
{
|
||||
dupefound = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user