[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.
This commit is contained in:
Matt Nadareski
2016-08-11 11:03:32 -07:00
parent 304af7d3b1
commit e4deb679a3
4 changed files with 21 additions and 8 deletions

View File

@@ -176,6 +176,9 @@ Options:
-c, --cascade Enable cascaded diffing -c, --cascade Enable cascaded diffing
-ip, --inplace Enable inplace, cascaded diff -ip, --inplace Enable inplace, cascaded diff
-sf, --skip Skip output of first DAT -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 -gn=, --game-name= Filter by game name
-rn=, --rom-name= Filter by rom name -rn=, --rom-name= Filter by rom name
-rt=, --rom-type= Filter by rom type -rt=, --rom-type= Filter by rom type

View File

@@ -1520,7 +1520,7 @@ namespace SabreTools.Helper
/// <param name="outputDirectory">Optional param for output directory</param> /// <param name="outputDirectory">Optional param for output directory</param>
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param> /// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
/// <param name="diff">True if the input files should be diffed with each other, false otherwise</param> /// <param name="diff">True if the input files should be diffed with each other, false otherwise</param>
/// <param name="cascade">True if the diffed files should be cascade diffed, false otherwise</param> /// <param name="cascade">True if the diffed files should be cascade diffed, false if diffed files should be reverse cascaded, null otherwise</param>
/// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param> /// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param>
/// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param> /// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
/// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param> /// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param>
@@ -1540,7 +1540,7 @@ namespace SabreTools.Helper
/// <param name="single">True if all games should be replaced by '!', false otherwise</param> /// <param name="single">True if all games should be replaced by '!', false otherwise</param>
/// <param name="root">String representing root directory to compare against for length calculation</param> /// <param name="root">String representing root directory to compare against for length calculation</param>
/// <param name="logger">Logging object for console and file output</param> /// <param name="logger">Logging object for console and file output</param>
public static void Update(List<string> inputFileNames, Dat datdata, string outputDirectory, bool merge, bool diff, bool cascade, bool inplace, public static void Update(List<string> 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, 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) 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 // Create a dictionary of all ROMs from the input DATs
datdata.FileName = datdata.Description; datdata.FileName = datdata.Description;
Dat userData; 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); 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 // Modify the Dictionary if necessary and output the results
if (diff && !cascade) if (diff && cascade == null)
{ {
DiffNoCascade(outputDirectory, userData, newInputFileNames, logger); DiffNoCascade(outputDirectory, userData, newInputFileNames, logger);
} }
// If we're in cascade and diff, output only cascaded diffs // 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); DiffCascade(outputDirectory, inplace, userData, newInputFileNames, datHeaders, skip, logger);
} }

View File

@@ -111,7 +111,7 @@ namespace SabreTools
/// /* Merging and Diffing info */ /// /* Merging and Diffing info */
/// <param name="merge">True if input files should be merged into a single file, false otherwise</param> /// <param name="merge">True if input files should be merged into a single file, false otherwise</param>
/// <param name="diff">True if the input files should be diffed with each other, false otherwise</param> /// <param name="diff">True if the input files should be diffed with each other, false otherwise</param>
/// <param name="cascade">True if the diffed files should be cascade diffed, false otherwise</param> /// <param name="cascade">True if the diffed files should be cascade diffed, false if diffed files should be reverse cascaded, null otherwise</param>
/// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param> /// <param name="inplace">True if the cascade-diffed files should overwrite their inputs, false otherwise</param>
/// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param> /// <param name="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
/// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param> /// <param name="bare">True if the date should not be appended to the default name, false otherwise [OBSOLETE]</param>
@@ -174,7 +174,7 @@ namespace SabreTools
/* Merging and Diffing info */ /* Merging and Diffing info */
bool merge, bool merge,
bool diff, bool diff,
bool cascade, bool? cascade,
bool inplace, bool inplace,
bool skip, bool skip,
bool bare, bool bare,

View File

@@ -81,7 +81,6 @@ namespace SabreTools
add = false, add = false,
archivesAsFiles = false, archivesAsFiles = false,
bare = false, bare = false,
cascade = false,
clean = false, clean = false,
datfromdir = false, datfromdir = false,
datprefix = false, datprefix = false,
@@ -122,7 +121,8 @@ namespace SabreTools
skip = false, skip = false,
update = false, update = false,
usegame = true; usegame = true;
bool? nodump = null; bool? cascade = null,
nodump = null;
long sgt = -1, long sgt = -1,
slt = -1, slt = -1,
seq = -1; seq = -1;
@@ -335,6 +335,10 @@ namespace SabreTools
case "--roms": case "--roms":
usegame = false; usegame = false;
break; break;
case "-rc":
case "--rev-cascade":
cascade = false;
break;
case "-rm": case "-rm":
case "--remove": case "--remove":
rem = true; rem = true;