mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatTools] Extract dupliate logic
This commit is contained in:
@@ -1490,20 +1490,8 @@ namespace SabreTools.Helper
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rom.Type == "rom" && lastrom.Type == "rom")
|
// Get the duplicate status
|
||||||
{
|
dupefound = RomDuplicate(rom, lastrom);
|
||||||
dupefound = ((rom.Size == lastrom.Size) &&
|
|
||||||
((String.IsNullOrEmpty(rom.CRC) || String.IsNullOrEmpty(lastrom.CRC)) || rom.CRC == lastrom.CRC) &&
|
|
||||||
((String.IsNullOrEmpty(rom.MD5) || String.IsNullOrEmpty(lastrom.MD5)) || rom.MD5 == lastrom.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(rom.SHA1) || String.IsNullOrEmpty(lastrom.SHA1)) || rom.SHA1 == lastrom.SHA1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else if (rom.Type == "disk" && lastrom.Type == "disk")
|
|
||||||
{
|
|
||||||
dupefound = (((String.IsNullOrEmpty(rom.MD5) || String.IsNullOrEmpty(lastrom.MD5)) || rom.MD5 == lastrom.MD5) &&
|
|
||||||
((String.IsNullOrEmpty(rom.SHA1) || String.IsNullOrEmpty(lastrom.SHA1)) || rom.SHA1 == lastrom.SHA1)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If it's a duplicate, skip adding it to the output but add any missing information
|
// If it's a duplicate, skip adding it to the output but add any missing information
|
||||||
if (dupefound)
|
if (dupefound)
|
||||||
@@ -1585,6 +1573,34 @@ namespace SabreTools.Helper
|
|||||||
return outroms;
|
return outroms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine if a file is a duplicate using partial matching logic
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rom">Rom to check for duplicate status</param>
|
||||||
|
/// <param name="lastrom">Rom to use as a baseline</param>
|
||||||
|
/// <returns>True if the roms are duplicates, false otherwise</returns>
|
||||||
|
public static bool RomDuplicate(RomData rom, RomData lastrom)
|
||||||
|
{
|
||||||
|
bool dupefound = false;
|
||||||
|
|
||||||
|
if (rom.Type == "rom" && lastrom.Type == "rom")
|
||||||
|
{
|
||||||
|
dupefound = ((rom.Size == lastrom.Size) &&
|
||||||
|
((String.IsNullOrEmpty(rom.CRC) || String.IsNullOrEmpty(lastrom.CRC)) || rom.CRC == lastrom.CRC) &&
|
||||||
|
((String.IsNullOrEmpty(rom.MD5) || String.IsNullOrEmpty(lastrom.MD5)) || rom.MD5 == lastrom.MD5) &&
|
||||||
|
((String.IsNullOrEmpty(rom.SHA1) || String.IsNullOrEmpty(lastrom.SHA1)) || rom.SHA1 == lastrom.SHA1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (rom.Type == "disk" && lastrom.Type == "disk")
|
||||||
|
{
|
||||||
|
dupefound = (((String.IsNullOrEmpty(rom.MD5) || String.IsNullOrEmpty(lastrom.MD5)) || rom.MD5 == lastrom.MD5) &&
|
||||||
|
((String.IsNullOrEmpty(rom.SHA1) || String.IsNullOrEmpty(lastrom.SHA1)) || rom.SHA1 == lastrom.SHA1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dupefound;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sort a list of RomData objects by SystemID, SourceID, Game, and Name (in order)
|
/// Sort a list of RomData objects by SystemID, SourceID, Game, and Name (in order)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user