[DatFile] Add quickscan to verify

This commit is contained in:
Matt Nadareski
2017-01-27 10:02:55 -08:00
parent a39cb80435
commit d46a2cac68
5 changed files with 14 additions and 5 deletions

View File

@@ -380,6 +380,7 @@ namespace SabreTools.Helper.Data
helptext.Add(" -dat= Input DAT to verify against"); helptext.Add(" -dat= Input DAT to verify against");
helptext.Add(" -t=, --temp= Set the temporary directory to use"); helptext.Add(" -t=, --temp= Set the temporary directory to use");
helptext.Add(" -ho, --hash-only Check files by hash only"); helptext.Add(" -ho, --hash-only Check files by hash only");
helptext.Add(" -qs, --quick Enable quick scanning of archives");
helptext.Add(" -h=, --header= Set a header skipper to use, blank means all"); helptext.Add(" -h=, --header= Set a header skipper to use, blank means all");
// Additional Notes // Additional Notes

View File

@@ -469,10 +469,11 @@ namespace SabreTools.Helper.Dats
/// <param name="inputs">List of input directories to compare against</param> /// <param name="inputs">List of input directories to compare against</param>
/// <param name="tempDir">Temporary directory for archive extraction</param> /// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="hashOnly">True if only hashes should be checked, false for full file information</param> /// <param name="hashOnly">True if only hashes should be checked, false for full file information</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param> /// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
/// <param name="logger">Logger object for file and console output</param> /// <param name="logger">Logger object for file and console output</param>
/// <returns>True if verification was a success, false otherwise</returns> /// <returns>True if verification was a success, false otherwise</returns>
public bool VerifyDirectory(List<string> inputs, string tempDir, bool hashOnly, string headerToCheckAgainst, Logger logger) public bool VerifyDirectory(List<string> inputs, string tempDir, bool hashOnly, bool quickScan, string headerToCheckAgainst, Logger logger)
{ {
// Check the temp directory exists // Check the temp directory exists
if (String.IsNullOrEmpty(tempDir)) if (String.IsNullOrEmpty(tempDir))
@@ -500,7 +501,7 @@ namespace SabreTools.Helper.Dats
logger.User("Processing files:\n"); logger.User("Processing files:\n");
foreach (string input in inputs) foreach (string input in inputs)
{ {
PopulateFromDir(input, false /* noMD5 */, false /* noSHA1 */, true /* bare */, false /* archivesAsFiles */, PopulateFromDir(input, quickScan /* noMD5 */, quickScan /* noSHA1 */, true /* bare */, false /* archivesAsFiles */,
true /* enableGzip */, false /* addBlanks */, false /* addDate */, tempDir /* tempDir */, false /* copyFiles */, true /* enableGzip */, false /* addBlanks */, false /* addDate */, tempDir /* tempDir */, false /* copyFiles */,
headerToCheckAgainst, 4 /* maxDegreeOfParallelism */, logger); headerToCheckAgainst, 4 /* maxDegreeOfParallelism */, logger);
} }

View File

@@ -906,6 +906,12 @@ Options:
This allows verification of (possibly) incorrectly named folders and sets to be This allows verification of (possibly) incorrectly named folders and sets to be
verified without worrying about the proper set structure to be there. verified without worrying about the proper set structure to be there.
-qs, --quick Enable quick scanning of archives
For all archives, if this flag is enabled, it will only use the header information
to get the archive entries' file information. The upside to this is that it is much
quicker than extracting all files to the temp folder. On the downside, it can only
get the CRC and size from most archive formats, leading to possible issues.
-h=, --header= Remove headers from hash calculations -h=, --header= Remove headers from hash calculations
If this is set, then all files that have copier headers that are detected will 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 have them removed from the hash calculation. This will allow for a headered collection

View File

@@ -790,8 +790,9 @@ namespace SabreTools
/// <param name="inputs">Input directories to compare against</param> /// <param name="inputs">Input directories to compare against</param>
/// <param name="tempDir">Temporary directory for archive extraction</param> /// <param name="tempDir">Temporary directory for archive extraction</param>
/// <param name="hashOnly">True if only hashes should be checked, false for full file information</param> /// <param name="hashOnly">True if only hashes should be checked, false for full file information</param>
/// <param name="quickScan">True to enable external scanning of archives, false otherwise</param>
/// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param> /// <param name="headerToCheckAgainst">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
private static void InitVerify(List<string> datfiles, List<string> inputs, string tempDir, bool hashOnly, string headerToCheckAgainst) private static void InitVerify(List<string> datfiles, List<string> inputs, string tempDir, bool hashOnly, bool quickScan, string headerToCheckAgainst)
{ {
// Get the archive scanning level // Get the archive scanning level
ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1); ArchiveScanLevel asl = ArchiveTools.GetArchiveScanLevelFromNumbers(1, 1, 1, 1);
@@ -807,7 +808,7 @@ namespace SabreTools
} }
_logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff")); _logger.User("Populating complete in " + DateTime.Now.Subtract(start).ToString(@"hh\:mm\:ss\.fffff"));
datdata.VerifyDirectory(inputs, tempDir, hashOnly, headerToCheckAgainst, _logger); datdata.VerifyDirectory(inputs, tempDir, hashOnly, quickScan, headerToCheckAgainst, _logger);
} }
#endregion #endregion

View File

@@ -1109,7 +1109,7 @@ namespace SabreTools
// If we're using the verifier // If we're using the verifier
else if (verify) else if (verify)
{ {
InitVerify(datfiles, inputs, tempDir, hashOnly, header); InitVerify(datfiles, inputs, tempDir, hashOnly, quickScan, header);
} }
// If nothing is set, show the help // If nothing is set, show the help