diff --git a/SabreTools.Helper/Tools/DatTools.cs b/SabreTools.Helper/Tools/DatTools.cs index 7deb4e07..e81d9590 100644 --- a/SabreTools.Helper/Tools/DatTools.cs +++ b/SabreTools.Helper/Tools/DatTools.cs @@ -1519,7 +1519,7 @@ namespace SabreTools.Helper /// User specified inputs contained in a DatData object /// Optional param for output directory /// True if input files should be merged into a single file, false otherwise - /// True if the input files should be diffed with each other, false otherwise + /// Non-zero flag for diffing mode, zero otherwise /// True if the diffed files should be cascade diffed, false if diffed files should be reverse cascaded, null otherwise /// True if the cascade-diffed files should overwrite their inputs, false otherwise /// True if the first cascaded diff file should be skipped on output, false otherwise @@ -1540,12 +1540,12 @@ namespace SabreTools.Helper /// True if all games should be replaced by '!', false otherwise /// String representing root directory to compare against for length calculation /// Logging object for console and file output - public static void Update(List inputFileNames, Dat datdata, string outputDirectory, bool merge, bool diff, bool? cascade, bool inplace, + public static void Update(List inputFileNames, Dat datdata, string outputDirectory, bool merge, DiffMode diff, bool? cascade, bool inplace, bool skip, bool bare, bool clean, bool softlist, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, bool? nodump, bool trim, bool single, string root, Logger logger) { // If we're in merging or diffing mode, use the full list of inputs - if (merge || diff) + if (merge || diff != 0) { // Make sure there are no folders in inputs List newInputFileNames = new List(); @@ -1601,12 +1601,12 @@ namespace SabreTools.Helper userData = Filter(userData, gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, logger); // Modify the Dictionary if necessary and output the results - if (diff && cascade == null) + if (diff != 0 && cascade == null) { DiffNoCascade(outputDirectory, userData, newInputFileNames, logger); } // If we're in cascade and diff, output only cascaded diffs - else if (diff && cascade != null) + else if (diff != 0 && cascade != null) { DiffCascade(outputDirectory, inplace, userData, newInputFileNames, datHeaders, skip, logger); } diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index 1b1dfc40..6862fe54 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -110,7 +110,7 @@ namespace SabreTools /// True to output files in TSV format, false to output files in CSV format, null otherwise /// /* Merging and Diffing info */ /// True if input files should be merged into a single file, false otherwise - /// True if the input files should be diffed with each other, false otherwise + /// Non-zero flag for diffing mode, zero otherwise /// True if the diffed files should be cascade diffed, false if diffed files should be reverse cascaded, null otherwise /// True if the cascade-diffed files should overwrite their inputs, false otherwise /// True if the first cascaded diff file should be skipped on output, false otherwise @@ -173,7 +173,7 @@ namespace SabreTools /* Merging and Diffing info */ bool merge, - bool diff, + DiffMode diff, bool? cascade, bool inplace, bool skip, @@ -256,7 +256,7 @@ namespace SabreTools repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext); // If we're in merge or diff mode and the names aren't set, set defaults - if (merge || diff) + if (merge || diff != 0) { // Get the values that will be used if (date == "") @@ -265,17 +265,17 @@ namespace SabreTools } if (name == "") { - name = (diff ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : ""); + name = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : ""); } if (description == "") { - description = (diff ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : ""); + description = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : ""); if (!bare) { description += " (" + date + ")"; } } - if (category == "" && diff) + if (category == "" && diff != 0) { category = "DiffDAT"; } @@ -350,7 +350,7 @@ namespace SabreTools } if (!outputCMP && !(outputMiss || tsv != null) && !outputRC && !outputSD && !outputXML) { - if (merge || diff) + if (merge || diff != 0) { userInputDat.OutputFormat = OutputFormat.Xml; } diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 65f758b9..c40c929f 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -85,7 +85,6 @@ namespace SabreTools datfromdir = false, datprefix = false, dedup = false, - diff = false, enableGzip = false, extsplit = false, fake = false, @@ -123,6 +122,7 @@ namespace SabreTools bool? cascade = null, nodump = null, tsv = null; + DiffMode diff = 0x0; long sgt = -1, slt = -1, seq = -1; @@ -225,7 +225,19 @@ namespace SabreTools break; case "-di": case "--diff": - diff = true; + diff |= DiffMode.All; + break; + case "-did": + case "--diff-du": + diff |= DiffMode.Dupes; + break; + case "-dii": + case "--diff-in": + diff |= DiffMode.Individuals; + break; + case "-din": + case "--diff-nd": + diff |= DiffMode.NoDupes; break; case "-es": case "--ext-split": @@ -583,7 +595,7 @@ namespace SabreTools // If more than one switch is enabled, show the help screen if (!(add ^ datfromdir ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ - (merge || diff || update || outputCMP || outputRC || outputSD || outputXML || outputMiss || tsv != null|| trim) ^ + (merge || diff != 0 || update || outputCMP || outputRC || outputSD || outputXML || outputMiss || tsv != null|| trim) ^ offlineMerge ^ rem ^ stats)) { _logger.Error("Only one feature switch is allowed at a time"); @@ -594,7 +606,7 @@ namespace SabreTools // If a switch that requires a filename is set and no file is, show the help screen if (inputs.Count == 0 && (update || (outputMiss || tsv != null) || outputCMP || outputRC || outputSD - || outputXML || extsplit || hashsplit || datfromdir || (merge || diff) || stats || trim)) + || outputXML || extsplit || hashsplit || datfromdir || (merge || diff != 0) || stats || trim)) { _logger.Error("This feature requires at least one input"); Build.Help(); @@ -637,7 +649,7 @@ namespace SabreTools } // Convert, update, merge, diff, and filter a DAT or folder of DATs - else if (update || outputCMP || outputMiss || tsv != null || outputRC || outputSD || outputXML || merge || diff) + else if (update || outputCMP || outputMiss || tsv != null || outputRC || outputSD || outputXML || merge || diff != 0) { InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header, superdat, forcemerge, forcend, forcepack, outputCMP, outputMiss, outputRC, outputSD, outputXML, usegame, prefix,