diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs
index 0020e3cd..ab14b344 100644
--- a/SabreTools.Helper/Data/Build.cs
+++ b/SabreTools.Helper/Data/Build.cs
@@ -379,6 +379,7 @@ namespace SabreTools.Helper.Data
helptext.Add(" -ve, --verify Verify a folder against DATs");
helptext.Add(" -dat= Input DAT to verify against");
helptext.Add(" -t=, --temp= Set the temporary directory to use");
+ helptext.Add(" -ho, --hash-only Check files by hash only");
helptext.Add(" -h=, --header= Set a header skipper to use, blank means all");
// Additional Notes
diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
index a4e0abde..10e4aff4 100644
--- a/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
+++ b/SabreTools.Helper/Dats/Partials/DatFile.Rebuild.cs
@@ -1,12 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
using SabreTools.Helper.Data;
using SabreTools.Helper.Skippers;
using SabreTools.Helper.Tools;
-using SharpCompress.Common;
#if MONO
using System.IO;
@@ -468,13 +466,13 @@ namespace SabreTools.Helper.Dats
///
/// Process the DAT and verify the output directory
///
- /// DAT to use to verify the directory
/// List of input directories to compare against
/// Temporary directory for archive extraction
+ /// True if only hashes should be checked, false for full file information
/// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise
/// Logger object for file and console output
/// True if verification was a success, false otherwise
- public bool VerifyDirectory(List inputs, string tempDir, string headerToCheckAgainst, Logger logger)
+ public bool VerifyDirectory(List inputs, string tempDir, bool hashOnly, string headerToCheckAgainst, Logger logger)
{
// First create or clean the temp directory
if (!Directory.Exists(tempDir))
@@ -509,18 +507,41 @@ namespace SabreTools.Helper.Dats
matched.Description = "fixDat_" + matched.Description;
matched.DatFormat = DatFormat.Logiqx;
- // Now that all files are parsed, get only files found in directory
+ // If we are checking hashes only, essentially diff the inputs
bool found = false;
- foreach (string key in Keys)
+ if (hashOnly)
{
- List roms = this[key];
- List newroms = DatItem.Merge(roms, logger);
- foreach (Rom rom in newroms)
+ // First we need to sort by hash to get duplicates
+ BucketBySHA1(true, logger, output: false);
+
+ // Then follow the same tactics as before
+ foreach (string key in Keys)
{
- if (rom.SourceID == 99)
+ List roms = this[key];
+ foreach (Rom rom in roms)
{
- found = true;
- matched.Add(rom.Size + "-" + rom.CRC, rom);
+ if (rom.SourceID == 99)
+ {
+ found = true;
+ matched.Add(rom.Size + "-" + rom.CRC, rom);
+ }
+ }
+ }
+ }
+ // If we are checking full names, get only files found in directory
+ else
+ {
+ foreach (string key in Keys)
+ {
+ List roms = this[key];
+ List newroms = DatItem.Merge(roms, logger);
+ foreach (Rom rom in newroms)
+ {
+ if (rom.SourceID == 99)
+ {
+ found = true;
+ matched.Add(rom.Size + "-" + rom.CRC, rom);
+ }
}
}
}
diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST
index fb72e6be..d497698a 100644
--- a/SabreTools.Helper/README.1ST
+++ b/SabreTools.Helper/README.1ST
@@ -901,6 +901,11 @@ Options:
(inside the running folder) is not preferred. This is used for any operations that
require an archive to be extracted.
+ -ho, --hash-only Check files by hash only
+ This sets a mode where files are not checked based on name but rather hash alone.
+ This allows verification of (possibly) incorrectly named folders and sets to be
+ verified without worrying about the proper set structure to be there.
+
-h=, --header= Remove headers from hash calculations
If this is set, then all files that have copier headers that are detected will
have them removed from the hash calculation. This will allow for a headered collection
diff --git a/SabreTools/Partials/SabreTools.Inits.cs b/SabreTools/Partials/SabreTools.Inits.cs
index 49cdfbeb..04e515ec 100644
--- a/SabreTools/Partials/SabreTools.Inits.cs
+++ b/SabreTools/Partials/SabreTools.Inits.cs
@@ -789,8 +789,9 @@ namespace SabreTools
/// Names of the DATs to compare against
/// Input directories to compare against
/// Temporary directory for archive extraction
+ /// True if only hashes should be checked, false for full file information
/// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise
- private static void InitVerify(List datfiles, List inputs, string tempDir, string headerToCheckAgainst)
+ private static void InitVerify(List datfiles, List inputs, string tempDir, bool hashOnly, string headerToCheckAgainst)
{
// Get the archive scanning level
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1);
@@ -806,7 +807,7 @@ namespace SabreTools
}
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
- datdata.VerifyDirectory(inputs, tempDir, headerToCheckAgainst, _logger);
+ datdata.VerifyDirectory(inputs, tempDir, hashOnly, headerToCheckAgainst, _logger);
}
#endregion
diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs
index 3f0c0a7c..e5488d94 100644
--- a/SabreTools/SabreTools.cs
+++ b/SabreTools/SabreTools.cs
@@ -78,6 +78,7 @@ namespace SabreTools
delete = false, // SimpleSort
enableGzip = false,
excludeOf = false,
+ hashOnly = false,
inplace = false,
inverse = false, // SimpleSort
merge = false,
@@ -306,6 +307,10 @@ namespace SabreTools
case "--gz-files":
enableGzip = true;
break;
+ case "-ho":
+ case "--hash-only":
+ hashOnly = true;
+ break;
case "-html":
case "--html":
statDatFormat |= StatDatFormat.HTML;
@@ -1104,7 +1109,7 @@ namespace SabreTools
// If we're using the verifier
else if (verify)
{
- InitVerify(datfiles, inputs, tempDir, header);
+ InitVerify(datfiles, inputs, tempDir, hashOnly, header);
}
// If nothing is set, show the help