mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs] Implement Equatable
This commit is contained in:
@@ -6,24 +6,43 @@ namespace SabreTools.Helper
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intermediate struct for holding and processing hash data
|
/// Intermediate struct for holding and processing hash data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct HashData : IComparable, IEquatable<HashData>
|
public struct HashData : IEquatable<HashData>
|
||||||
{
|
{
|
||||||
public long Size;
|
public long Size;
|
||||||
public string CRC;
|
public string CRC;
|
||||||
public string MD5;
|
public string MD5;
|
||||||
public string SHA1;
|
public string SHA1;
|
||||||
|
|
||||||
// Needs implementation
|
|
||||||
public int CompareTo(object obj)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Needs implementation
|
|
||||||
public bool Equals(HashData other)
|
public bool Equals(HashData other)
|
||||||
|
{
|
||||||
|
if ((this.Size == other.Size) &&
|
||||||
|
((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 true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Equals(HashData other, bool IsDisk)
|
||||||
|
{
|
||||||
|
if (IsDisk)
|
||||||
|
{
|
||||||
|
HashData newthis = this;
|
||||||
|
newthis.Size = Constants.SizeZero;
|
||||||
|
newthis.CRC = Constants.CRCZero;
|
||||||
|
|
||||||
|
HashData newother = other;
|
||||||
|
newother.Size = Constants.SizeZero;
|
||||||
|
newother.CRC = Constants.CRCZero;
|
||||||
|
|
||||||
|
return newthis.Equals(newother);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.Equals(other);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -251,17 +251,11 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
if (rom.Type == "rom" && lastrom.Type == "rom")
|
if (rom.Type == "rom" && lastrom.Type == "rom")
|
||||||
{
|
{
|
||||||
dupefound = ((rom.HashData.Size == lastrom.HashData.Size) &&
|
dupefound = rom.HashData.Equals(lastrom.HashData, false);
|
||||||
((String.IsNullOrEmpty(rom.HashData.CRC) || String.IsNullOrEmpty(lastrom.HashData.CRC)) || rom.HashData.CRC == lastrom.HashData.CRC) &&
|
|
||||||
((String.IsNullOrEmpty(rom.HashData.MD5) || String.IsNullOrEmpty(lastrom.HashData.MD5)) || rom.HashData.MD5 == lastrom.HashData.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(rom.HashData.SHA1) || String.IsNullOrEmpty(lastrom.HashData.SHA1)) || rom.HashData.SHA1 == lastrom.HashData.SHA1)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else if (rom.Type == "disk" && lastrom.Type == "disk")
|
else if (rom.Type == "disk" && lastrom.Type == "disk")
|
||||||
{
|
{
|
||||||
dupefound = (((String.IsNullOrEmpty(rom.HashData.MD5) || String.IsNullOrEmpty(lastrom.HashData.MD5)) || rom.HashData.MD5 == lastrom.HashData.MD5) &&
|
dupefound = rom.HashData.Equals(lastrom.HashData, true);
|
||||||
((String.IsNullOrEmpty(rom.HashData.SHA1) || String.IsNullOrEmpty(lastrom.HashData.SHA1)) || rom.HashData.SHA1 == lastrom.HashData.SHA1)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// More wonderful SHA-1 logging that has to be done
|
// More wonderful SHA-1 logging that has to be done
|
||||||
|
|||||||
Reference in New Issue
Block a user