From e4deb679a33b3cc72cb6f0936e736406db5b43d2 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 11 Aug 2016 11:03:32 -0700 Subject: [PATCH] [DatTools] Add reverse cascade Add reverse cascaded diffing. Essentially this just reverses the list of input files so that the last file is treated as the first and so on. Has not been tested. --- SabreTools.Helper/Data/Build.cs | 3 +++ SabreTools.Helper/Tools/DatTools.cs | 14 ++++++++++---- SabreTools/Partials/SabreTools_Inits.cs | 4 ++-- SabreTools/SabreTools.cs | 8 ++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index 4036ab7c..554e4842 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -176,6 +176,9 @@ Options: -c, --cascade Enable cascaded diffing -ip, --inplace Enable inplace, cascaded diff -sf, --skip Skip output of first DAT + -rc, --rev-cascade Enable reverse cascaded diffing + -ip, --inplace Enable inplace, cascaded diff + -sf, --skip Skip output of first DAT -gn=, --game-name= Filter by game name -rn=, --rom-name= Filter by rom name -rt=, --rom-type= Filter by rom type diff --git a/SabreTools.Helper/Tools/DatTools.cs b/SabreTools.Helper/Tools/DatTools.cs index e102123b..a1ad85b2 100644 --- a/SabreTools.Helper/Tools/DatTools.cs +++ b/SabreTools.Helper/Tools/DatTools.cs @@ -1520,7 +1520,7 @@ namespace SabreTools.Helper /// 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 - /// True if the diffed files should be cascade diffed, false 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 /// True if the date should not be appended to the default name, false otherwise [OBSOLETE] @@ -1540,7 +1540,7 @@ 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, bool 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) { @@ -1586,6 +1586,12 @@ namespace SabreTools.Helper } } + // If we're in inverse cascade, reverse the list + if (cascade == false) + { + newInputFileNames.Reverse(); + } + // Create a dictionary of all ROMs from the input DATs datdata.FileName = datdata.Description; Dat userData; @@ -1595,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) + if (diff && cascade == null) { DiffNoCascade(outputDirectory, userData, newInputFileNames, logger); } // If we're in cascade and diff, output only cascaded diffs - else if (diff && cascade) + else if (diff && 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 ef5f9935..adeea5d5 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -111,7 +111,7 @@ namespace SabreTools /// /* 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 - /// True if the diffed files should be cascade diffed, false 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 /// True if the date should not be appended to the default name, false otherwise [OBSOLETE] @@ -174,7 +174,7 @@ namespace SabreTools /* Merging and Diffing info */ bool merge, bool diff, - bool cascade, + bool? cascade, bool inplace, bool skip, bool bare, diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 53a9c8c9..426b4ea2 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -81,7 +81,6 @@ namespace SabreTools add = false, archivesAsFiles = false, bare = false, - cascade = false, clean = false, datfromdir = false, datprefix = false, @@ -122,7 +121,8 @@ namespace SabreTools skip = false, update = false, usegame = true; - bool? nodump = null; + bool? cascade = null, + nodump = null; long sgt = -1, slt = -1, seq = -1; @@ -335,6 +335,10 @@ namespace SabreTools case "--roms": usegame = false; break; + case "-rc": + case "--rev-cascade": + cascade = false; + break; case "-rm": case "--remove": rem = true;