From 467586cf0efb774f344c611c9b418771273cb4f6 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 31 Jul 2020 14:04:10 -0700 Subject: [PATCH] Add output dir to Verify --- SabreTools.Library/DatFiles/DatFile.cs | 18 ++++++++++-------- SabreTools.Library/README.1ST | 4 ++++ SabreTools/SabreTools.Help.cs | 10 ++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 6a430bba..2b1d88af 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -21,7 +21,7 @@ namespace SabreTools.Library.DatFiles /// public abstract class DatFile { - #region Publically available fields + #region Fields /// /// Header values @@ -48,7 +48,7 @@ namespace SabreTools.Library.DatFiles if (datFile != null) { Header = datFile.Header; - this.Items = datFile.Items; + Items = datFile.Items; } } @@ -2556,8 +2556,9 @@ namespace SabreTools.Library.DatFiles /// Process the DAT and verify from the depots /// /// List of input directories to compare against + /// Optional param for output directory /// True if verification was a success, false otherwise - public bool VerifyDepot(List inputs) + public bool VerifyDepot(List inputs, string outDir) { bool success = true; @@ -2629,7 +2630,7 @@ namespace SabreTools.Library.DatFiles Header.Name = $"fixDAT_{Header.Name}"; Header.Description = $"fixDAT_{Header.Description}"; Items.ClearMarked(); - Write(); + Write(outDir, stats: true); return success; } @@ -2638,13 +2639,14 @@ namespace SabreTools.Library.DatFiles /// Process the DAT and verify the output directory /// /// List of input directories to compare against + /// Optional param for output directory /// True if only hashes should be checked, false for full file information /// True to enable external scanning of archives, false otherwise /// Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise /// True if CHDs should be treated like regular files, false otherwise /// Filter object to be passed to the DatItem level /// True if verification was a success, false otherwise - public bool VerifyGeneric(List inputs, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool chdsAsFiles, Filter filter) + public bool VerifyGeneric(List inputs, string outDir, bool hashOnly, bool quickScan, string headerToCheckAgainst, bool chdsAsFiles, Filter filter) { // TODO: We want the cross section of what's the folder and what's in the DAT. Right now, it just has what's in the DAT that's not in the folder bool success = true; @@ -2703,7 +2705,7 @@ namespace SabreTools.Library.DatFiles // Now output the fixdat to the main folder Items.ClearMarked(); - success &= matched.Write(stats: true); + success &= matched.Write(outDir, stats: true); return success; } @@ -3119,13 +3121,13 @@ namespace SabreTools.Library.DatFiles /// /// Create and open an output file for writing direct from a dictionary /// - /// Set the output directory (default current directory) + /// Set the output directory (current directory on null) /// True if games should only be compared on game and file name (default), false if system and source are counted /// True if DAT statistics should be output on write, false otherwise (default) /// True if blank roms should be skipped on output, false otherwise (default) /// True if files should be overwritten (default), false if they should be renamed instead /// True if the DAT was written correctly, false otherwise - public bool Write(string outDir = null, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true) + public bool Write(string outDir, bool norename = true, bool stats = false, bool ignoreblanks = false, bool overwrite = true) { // If there's nothing there, abort if (Items.TotalCount == 0) diff --git a/SabreTools.Library/README.1ST b/SabreTools.Library/README.1ST index e164b4ae..a483fb23 100644 --- a/SabreTools.Library/README.1ST +++ b/SabreTools.Library/README.1ST @@ -1505,6 +1505,10 @@ Options: Optionally, a temp folder can be supplied in the case the default temp directory is not preferred. + -out=, --output-dir= Output directory + This sets an output folder to be used when the files are created. If + a path is not defined, the runtime directory is used instead. + -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 diff --git a/SabreTools/SabreTools.Help.cs b/SabreTools/SabreTools.Help.cs index ddeda8c4..0441a811 100644 --- a/SabreTools/SabreTools.Help.cs +++ b/SabreTools/SabreTools.Help.cs @@ -3521,6 +3521,7 @@ The stats that are outputted are as follows: AddFeature(DatListInput); AddFeature(DepotFlag); AddFeature(TempStringInput); + AddFeature(OutputDirStringInput); AddFeature(HashOnlyFlag); AddFeature(QuickFlag); AddFeature(HeaderStringInput); @@ -3577,6 +3578,7 @@ The stats that are outputted are as follows: var datfilePaths = DirectoryExtensions.GetFilesOnly(datfiles); // Get feature flags + string outDir = GetString(features, OutputDirStringValue); bool chdsAsFiles = GetBoolean(features, ChdsAsFilesValue); bool depot = GetBoolean(features, DepotValue); bool hashOnly = GetBoolean(features, HashOnlyValue); @@ -3595,9 +3597,9 @@ The stats that are outputted are as follows: // If we have the depot flag, respect it if (depot) - datdata.VerifyDepot(Inputs); + datdata.VerifyDepot(Inputs, outDir); else - datdata.VerifyGeneric(Inputs, hashOnly, quickScan, headerToCheckAgainst, chdsAsFiles, filter); + datdata.VerifyGeneric(Inputs, outDir, hashOnly, quickScan, headerToCheckAgainst, chdsAsFiles, filter); } } // Otherwise, process all DATs into the same output @@ -3617,9 +3619,9 @@ The stats that are outputted are as follows: // If we have the depot flag, respect it if (depot) - datdata.VerifyDepot(Inputs); + datdata.VerifyDepot(Inputs, outDir); else - datdata.VerifyGeneric(Inputs, hashOnly, quickScan, headerToCheckAgainst, chdsAsFiles, filter); + datdata.VerifyGeneric(Inputs, outDir, hashOnly, quickScan, headerToCheckAgainst, chdsAsFiles, filter); } } }