[SabreTools, DatTools] First implementation of flag

This commit is contained in:
Matt Nadareski
2016-08-26 12:00:19 -07:00
parent 81f35c433d
commit 5f6294af9a
3 changed files with 29 additions and 17 deletions

View File

@@ -1519,7 +1519,7 @@ namespace SabreTools.Helper
/// <param name="datdata">User specified inputs contained in a DatData object</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="diff">True if the input files should be diffed with each other, false otherwise</param>
/// <param name="diff">Non-zero flag for diffing mode, zero 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="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
@@ -1540,12 +1540,12 @@ namespace SabreTools.Helper
/// <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="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, 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<string> newInputFileNames = new List<string>();
@@ -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);
}

View File

@@ -110,7 +110,7 @@ namespace SabreTools
/// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param>
/// /* Merging and Diffing info */
/// <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">Non-zero flag for diffing mode, zero 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="skip">True if the first cascaded diff file should be skipped on output, false otherwise</param>
@@ -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;
}

View File

@@ -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,