mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Make equals make more sense for HashData
This commit is contained in:
@@ -15,33 +15,29 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
public bool Equals(HashData other)
|
public bool Equals(HashData other)
|
||||||
{
|
{
|
||||||
if ((this.Size == other.Size) &&
|
return this.Equals(other, false);
|
||||||
((String.IsNullOrEmpty(this.CRC) || String.IsNullOrEmpty(other.CRC)) || this.CRC == other.CRC) &&
|
|
||||||
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(HashData other, bool IsDisk)
|
public bool Equals(HashData other, bool IsDisk)
|
||||||
{
|
{
|
||||||
if (IsDisk)
|
bool equals = false;
|
||||||
|
|
||||||
|
if (!IsDisk &&
|
||||||
|
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
||||||
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
||||||
{
|
{
|
||||||
HashData newthis = this;
|
equals = true;
|
||||||
newthis.Size = Constants.SizeZero;
|
}
|
||||||
newthis.CRC = Constants.CRCZero;
|
else if (!IsDisk &&
|
||||||
|
(this.Size == other.Size) &&
|
||||||
HashData newother = other;
|
((String.IsNullOrEmpty(this.CRC) || String.IsNullOrEmpty(other.CRC)) || this.CRC == other.CRC) &&
|
||||||
newother.Size = Constants.SizeZero;
|
((String.IsNullOrEmpty(this.MD5) || String.IsNullOrEmpty(other.MD5)) || this.MD5 == other.MD5) &&
|
||||||
newother.CRC = Constants.CRCZero;
|
((String.IsNullOrEmpty(this.SHA1) || String.IsNullOrEmpty(other.SHA1)) || this.SHA1 == other.SHA1))
|
||||||
|
{
|
||||||
return newthis.Equals(newother);
|
equals = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.Equals(other);
|
return equals;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user