mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] More work on conversion
This commit is contained in:
@@ -350,6 +350,26 @@ namespace SabreTools.Helper
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine if a file is a duplicate using partial matching logic
|
||||
/// </summary>
|
||||
/// <param name="hash">Hash to check for duplicate status</param>
|
||||
/// <param name="lasthash">Hash to use as a baseline</param>
|
||||
/// <param name="logger">Logger object for console and/or file output</param>
|
||||
/// <returns>True if the hashes are duplicates, false otherwise</returns>
|
||||
public static bool IsDuplicate(HashData hash, HashData lasthash, Logger logger)
|
||||
{
|
||||
bool dupefound = hash.Equals(lasthash);
|
||||
|
||||
// More wonderful SHA-1 logging that has to be done
|
||||
if (hash.SHA1 == lasthash.SHA1 && hash.Size != lasthash.Size)
|
||||
{
|
||||
logger.User("SHA-1 mismatch - Hash: " + hash.SHA1);
|
||||
}
|
||||
|
||||
return dupefound;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the duplicate status of two roms
|
||||
/// </summary>
|
||||
@@ -396,6 +416,52 @@ namespace SabreTools.Helper
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the duplicate status of two hashes
|
||||
/// </summary>
|
||||
/// <param name="hash">Current hash to check</param>
|
||||
/// <param name="lasthash">Last hash to check against</param>
|
||||
/// <param name="logger">Logger object for console and/or file output</param>
|
||||
/// <returns>The DupeType corresponding to the relationship between the two</returns>
|
||||
public static DupeType GetDuplicateStatus(HashData hash, HashData lasthash, Logger logger)
|
||||
{
|
||||
DupeType output = DupeType.None;
|
||||
|
||||
// If we don't have a duplicate at all, return none
|
||||
if (!IsDuplicate(hash, lasthash, logger))
|
||||
{
|
||||
return output;
|
||||
}
|
||||
|
||||
// If the duplicate is external already or should be, set it
|
||||
if (lasthash.Roms[0].DupeType >= DupeType.ExternalHash || lasthash.Roms[0].Machine.SystemID != hash.Roms[0].Machine.SystemID || lasthash.Roms[0].Machine.SourceID != hash.Roms[0].Machine.SourceID)
|
||||
{
|
||||
if (lasthash.Roms[0].Machine.Name == hash.Roms[0].Machine.Name && lasthash.Roms[0].Name == hash.Roms[0].Name)
|
||||
{
|
||||
output = DupeType.ExternalAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
output = DupeType.ExternalHash;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, it's considered an internal dupe
|
||||
else
|
||||
{
|
||||
if (lasthash.Roms[0].Machine.Name == hash.Roms[0].Machine.Name && lasthash.Roms[0].Name == hash.Roms[0].Name)
|
||||
{
|
||||
output = DupeType.InternalAll;
|
||||
}
|
||||
else
|
||||
{
|
||||
output = DupeType.InternalHash;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sort a list of RomData objects by SystemID, SourceID, Game, and Name (in order)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user