mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Structs, RomTools] Move Rom comparison to struct
This commit is contained in:
@@ -87,14 +87,26 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
public bool Equals(Rom other)
|
public bool Equals(Rom other)
|
||||||
{
|
{
|
||||||
Logger temp = new Logger(false, "");
|
bool dupefound = false;
|
||||||
temp.Start();
|
|
||||||
bool isdupe = RomTools.IsDuplicate(this, other, temp);
|
|
||||||
temp.Close();
|
|
||||||
|
|
||||||
return (this.Machine.Name == other.Machine.Name &&
|
// If either is a nodump, it's never a match
|
||||||
|
if (this.Nodump || other.Nodump)
|
||||||
|
{
|
||||||
|
return dupefound;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Type == ItemType.Rom && other.Type == ItemType.Rom)
|
||||||
|
{
|
||||||
|
dupefound = this.HashData.Equals(other.HashData, false);
|
||||||
|
}
|
||||||
|
else if (this.Type == ItemType.Disk && other.Type == ItemType.Disk)
|
||||||
|
{
|
||||||
|
dupefound = this.HashData.Equals(other.HashData, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (this.Machine.Equals(other.Machine) &&
|
||||||
this.Name == other.Name &&
|
this.Name == other.Name &&
|
||||||
isdupe);
|
dupefound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +124,7 @@ namespace SabreTools.Helper
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Intermediate struct for holding and processing Rom/Machine data
|
/// Intermediate struct for holding and processing Rom/Machine data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public struct Machine
|
public struct Machine : IEquatable<Machine>
|
||||||
{
|
{
|
||||||
public string Name;
|
public string Name;
|
||||||
public string Comment;
|
public string Comment;
|
||||||
@@ -127,6 +139,16 @@ namespace SabreTools.Helper
|
|||||||
public string Board;
|
public string Board;
|
||||||
public string RebuildTo;
|
public string RebuildTo;
|
||||||
public bool TorrentZipped;
|
public bool TorrentZipped;
|
||||||
|
|
||||||
|
public bool Equals(Machine other)
|
||||||
|
{
|
||||||
|
if (this.Name == other.Name)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -241,22 +241,7 @@ namespace SabreTools.Helper
|
|||||||
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
||||||
public static bool IsDuplicate(Rom rom, Rom lastrom, Logger logger)
|
public static bool IsDuplicate(Rom rom, Rom lastrom, Logger logger)
|
||||||
{
|
{
|
||||||
bool dupefound = false;
|
bool dupefound = rom.Equals(lastrom);
|
||||||
|
|
||||||
// If either is a nodump, it's never a match
|
|
||||||
if (rom.Nodump || lastrom.Nodump)
|
|
||||||
{
|
|
||||||
return dupefound;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rom.Type == ItemType.Rom && lastrom.Type == ItemType.Rom)
|
|
||||||
{
|
|
||||||
dupefound = rom.HashData.Equals(lastrom.HashData, false);
|
|
||||||
}
|
|
||||||
else if (rom.Type == ItemType.Disk && lastrom.Type == ItemType.Disk)
|
|
||||||
{
|
|
||||||
dupefound = rom.HashData.Equals(lastrom.HashData, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// More wonderful SHA-1 logging that has to be done
|
// More wonderful SHA-1 logging that has to be done
|
||||||
if (rom.HashData.SHA1 == lastrom.HashData.SHA1 && rom.HashData.Size != lastrom.HashData.Size)
|
if (rom.HashData.SHA1 == lastrom.HashData.SHA1 && rom.HashData.Size != lastrom.HashData.Size)
|
||||||
|
|||||||
Reference in New Issue
Block a user