[SabreTools] Consolodate diffing flags, add exclude of tag

This commit is contained in:
Matt Nadareski
2016-10-04 10:26:19 -07:00
parent 1338764eb6
commit 2082a9dde2
6 changed files with 65 additions and 31 deletions

View File

@@ -131,6 +131,7 @@ namespace SabreTools.Helper
helptext.Add(" -v=, --version= Set the version of the DAT"); helptext.Add(" -v=, --version= Set the version of the DAT");
helptext.Add(" -au=, --author= Set the author of the DAT"); helptext.Add(" -au=, --author= Set the author of the DAT");
helptext.Add(" -sd, --superdat Enable SuperDAT creation"); helptext.Add(" -sd, --superdat Enable SuperDAT creation");
helptext.Add(" -xof, --exclude-of Exclude romof, cloneof, sampleof tags");
helptext.Add(" -ab, --add-blank Output blank files for folders"); helptext.Add(" -ab, --add-blank Output blank files for folders");
helptext.Add(" -ad, --add-date Output dates for each file parsed"); helptext.Add(" -ad, --add-date Output dates for each file parsed");
helptext.Add(" -cf, --copy-files Copy files to the temp directory before parsing"); helptext.Add(" -cf, --copy-files Copy files to the temp directory before parsing");
@@ -205,6 +206,7 @@ namespace SabreTools.Helper
helptext.Add(" -fp=, --forcepack= Set force packing"); helptext.Add(" -fp=, --forcepack= Set force packing");
helptext.Add(" Supported values are:"); helptext.Add(" Supported values are:");
helptext.Add(" None, Zip, Unzip"); helptext.Add(" None, Zip, Unzip");
helptext.Add(" -xof, --exclude-of Exclude romof, cloneof, sampleof tags");
helptext.Add(" -clean Clean game names according to WoD standards"); helptext.Add(" -clean Clean game names according to WoD standards");
helptext.Add(" -sl, --softlist Use Software List name instead of description"); helptext.Add(" -sl, --softlist Use Software List name instead of description");
helptext.Add(" -trim Trim file names to fit NTFS length"); helptext.Add(" -trim Trim file names to fit NTFS length");

View File

@@ -8,10 +8,15 @@ namespace SabreTools.Helper
[Flags] [Flags]
public enum DiffMode public enum DiffMode
{ {
// Standard diffs
Dupes = 0x01, Dupes = 0x01,
NoDupes = 0x02, NoDupes = 0x02,
Individuals = 0x04, Individuals = 0x04,
All = Dupes | NoDupes | Individuals, All = Dupes | NoDupes | Individuals,
// Cascaded diffs
Cascade = 0x08,
ReverseCascade = 0x10,
} }
/// <summary> /// <summary>

View File

@@ -34,6 +34,7 @@ namespace SabreTools.Helper
private ForceNodump _forceNodump; private ForceNodump _forceNodump;
private ForcePacking _forcePacking; private ForcePacking _forcePacking;
private OutputFormat _outputFormat; private OutputFormat _outputFormat;
private bool _excludeOf;
private bool _mergeRoms; private bool _mergeRoms;
private SortedDictionary<string, List<DatItem>> _files; private SortedDictionary<string, List<DatItem>> _files;
@@ -154,6 +155,11 @@ namespace SabreTools.Helper
get { return _outputFormat; } get { return _outputFormat; }
set { _outputFormat = value; } set { _outputFormat = value; }
} }
public bool ExcludeOf
{
get { return _excludeOf; }
set { _excludeOf = value; }
}
public bool MergeRoms public bool MergeRoms
{ {
get { return _mergeRoms; } get { return _mergeRoms; }
@@ -567,7 +573,6 @@ namespace SabreTools.Helper
/// <param name="outDir">Optional param for output directory</param> /// <param name="outDir">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">Non-zero flag for diffing mode, zero 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="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>
@@ -588,7 +593,7 @@ namespace SabreTools.Helper
/// <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="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param> /// <param name="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</param>
/// <param name="logger">Logging object for console and file output</param> /// <param name="logger">Logging object for console and file output</param>
public void Update(List<string> inputFileNames, string outDir, bool merge, DiffMode diff, bool? cascade, bool inplace, bool skip, public void Update(List<string> inputFileNames, string outDir, bool merge, DiffMode diff, 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 bare, bool clean, bool softlist, string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc,
string md5, string sha1, ItemStatus itemStatus, bool trim, bool single, string root, int maxDegreeOfParallelism, Logger logger) string md5, string sha1, ItemStatus itemStatus, bool trim, bool single, string root, int maxDegreeOfParallelism, Logger logger)
{ {
@@ -636,7 +641,7 @@ namespace SabreTools.Helper
} }
// If we're in inverse cascade, reverse the list // If we're in inverse cascade, reverse the list
if (cascade == false) if ((diff & DiffMode.ReverseCascade) != 0)
{ {
newInputFileNames.Reverse(); newInputFileNames.Reverse();
} }
@@ -647,12 +652,12 @@ namespace SabreTools.Helper
crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, logger); crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, logger);
// Modify the Dictionary if necessary and output the results // Modify the Dictionary if necessary and output the results
if (diff != 0 && cascade == null) if (diff != 0 && diff < DiffMode.Cascade)
{ {
DiffNoCascade(diff, outDir, newInputFileNames, logger); DiffNoCascade(diff, outDir, 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 != 0 && cascade != null) else if (diff != 0 && diff >= DiffMode.Cascade)
{ {
DiffCascade(outDir, inplace, newInputFileNames, datHeaders, skip, logger); DiffCascade(outDir, inplace, newInputFileNames, datHeaders, skip, logger);
} }
@@ -3777,8 +3782,11 @@ namespace SabreTools.Helper
{ {
case OutputFormat.ClrMamePro: case OutputFormat.ClrMamePro:
state += "game (\n\tname \"" + rom.MachineName + "\"\n" + state += "game (\n\tname \"" + rom.MachineName + "\"\n" +
(String.IsNullOrEmpty(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") + (ExcludeOf ? "" :
(String.IsNullOrEmpty(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") + (String.IsNullOrEmpty(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") +
(String.IsNullOrEmpty(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") +
(String.IsNullOrEmpty(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n")
) +
"\tdescription \"" + (String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" + "\tdescription \"" + (String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription) + "\"\n" +
(String.IsNullOrEmpty(rom.Year) ? "" : "\tyear " + rom.Year + "\n") + (String.IsNullOrEmpty(rom.Year) ? "" : "\tyear " + rom.Year + "\n") +
(String.IsNullOrEmpty(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n"); (String.IsNullOrEmpty(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n");
@@ -3789,15 +3797,17 @@ namespace SabreTools.Helper
case OutputFormat.Logiqx: case OutputFormat.Logiqx:
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" + state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" +
(rom.IsBios ? " isbios=\"yes\"" : "") + (rom.IsBios ? " isbios=\"yes\"" : "") +
(String.IsNullOrEmpty(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant()) (ExcludeOf ? "" :
? "" (String.IsNullOrEmpty(rom.CloneOf) || (rom.MachineName.ToLowerInvariant() == rom.CloneOf.ToLowerInvariant())
: " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") + ? ""
(String.IsNullOrEmpty(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant()) : " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") +
? "" (String.IsNullOrEmpty(rom.RomOf) || (rom.MachineName.ToLowerInvariant() == rom.RomOf.ToLowerInvariant())
: " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") + ? ""
(String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant()) : " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") +
? "" (String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant())
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"") + ? ""
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"")
) +
">\n" + ">\n" +
(String.IsNullOrEmpty(rom.Comment) ? "" : "\t\t<comment>" + HttpUtility.HtmlEncode(rom.Comment) + "</comment>\n") + (String.IsNullOrEmpty(rom.Comment) ? "" : "\t\t<comment>" + HttpUtility.HtmlEncode(rom.Comment) + "</comment>\n") +
"\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "</description>\n" + "\t\t<description>" + HttpUtility.HtmlEncode((String.IsNullOrEmpty(rom.MachineDescription) ? rom.MachineName : rom.MachineDescription)) + "</description>\n" +

View File

@@ -227,6 +227,10 @@ Options:
Set the type flag to "SuperDAT" for the output DAT as well as preserving the Set the type flag to "SuperDAT" for the output DAT as well as preserving the
directory structure of the inputted folder, if applicable directory structure of the inputted folder, if applicable
-xof, --exclude-of Exclude romof, cloneof, sampleof tags
If this flag is enabled, then the romof, cloneof, and sampleof tags will be
omitted from the outputted DAT or DATs.
-ab, --add-blank Output blank files for folders -ab, --add-blank Output blank files for folders
If this flag is set, then blank entries will be created for each of the empty If this flag is set, then blank entries will be created for each of the empty
directories in the source. This is useful for tools that require all folders directories in the source. This is useful for tools that require all folders
@@ -510,6 +514,10 @@ Options:
Set the forcepacking flag to one of the supported values: Set the forcepacking flag to one of the supported values:
None, Zip, Unzip None, Zip, Unzip
-xof, --exclude-of Exclude romof, cloneof, sampleof tags
If this flag is enabled, then the romof, cloneof, and sampleof tags will be
omitted from the outputted DAT or DATs.
-clean Clean game names according to WoD standards -clean Clean game names according to WoD standards
Game names will be santitized to remove what the original WoD standards Game names will be santitized to remove what the original WoD standards
deemed as unneeded information, such as parenthized or bracketed strings deemed as unneeded information, such as parenthized or bracketed strings

View File

@@ -58,7 +58,8 @@ namespace SabreTools
/// <param name="category">New category</param> /// <param name="category">New category</param>
/// <param name="version">New version</param> /// <param name="version">New version</param>
/// <param name="author">New author</param> /// <param name="author">New author</param>
/// <param name="forceunpack">True to set forcepacking="unzip" on the created file, false otherwise</param> /// <param name="forcepack">String representing the forcepacking flag</param>
/// <param name="excludeOf">True if cloneof, romof, and sampleof fields should be omitted from output, false otherwise</param>
/// <param name="outputFormat">OutputFormat to be used for outputting the DAT</param> /// <param name="outputFormat">OutputFormat to be used for outputting the DAT</param>
/// <param name="romba">True to enable reading a directory like a Romba depot, false otherwise</param> /// <param name="romba">True to enable reading a directory like a Romba depot, false otherwise</param>
/// <param name="superdat">True to enable SuperDAT-style reading, false otherwise</param> /// <param name="superdat">True to enable SuperDAT-style reading, false otherwise</param>
@@ -81,6 +82,7 @@ namespace SabreTools
string version, string version,
string author, string author,
string forcepack, string forcepack,
bool excludeOf,
OutputFormat outputFormat, OutputFormat outputFormat,
bool romba, bool romba,
bool superdat, bool superdat,
@@ -124,6 +126,7 @@ namespace SabreTools
ForcePacking = fp, ForcePacking = fp,
OutputFormat = (outputFormat == 0 ? OutputFormat.Logiqx : outputFormat), OutputFormat = (outputFormat == 0 ? OutputFormat.Logiqx : outputFormat),
Romba = romba, Romba = romba,
ExcludeOf = excludeOf,
Type = (superdat ? "SuperDAT" : ""), Type = (superdat ? "SuperDAT" : ""),
Files = new SortedDictionary<string, List<DatItem>>(), Files = new SortedDictionary<string, List<DatItem>>(),
}; };
@@ -364,6 +367,7 @@ namespace SabreTools
/// <param name="forcemerge">None, Split, Full</param> /// <param name="forcemerge">None, Split, Full</param>
/// <param name="forcend">None, Obsolete, Required, Ignore</param> /// <param name="forcend">None, Obsolete, Required, Ignore</param>
/// <param name="forcepack">None, Zip, Unzip</param> /// <param name="forcepack">None, Zip, Unzip</param>
/// <param name="excludeOf">True if cloneof, romof, and sampleof fields should be omitted from output, false otherwise</param>
/// <param name="outputFormat">Non-zero flag for output format, zero otherwise for default</param> /// <param name="outputFormat">Non-zero flag for output format, zero otherwise for default</param>
/// /* Missfile-specific DAT info */ /// /* Missfile-specific DAT info */
/// <param name="usegame">True if games are to be used in output, false if roms are</param> /// <param name="usegame">True if games are to be used in output, false if roms are</param>
@@ -379,7 +383,6 @@ 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="diffMode">Non-zero flag for diffing mode, zero otherwise</param> /// <param name="diffMode">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="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>
@@ -424,6 +427,7 @@ namespace SabreTools
string forcemerge, string forcemerge,
string forcend, string forcend,
string forcepack, string forcepack,
bool excludeOf,
OutputFormat outputFormat, OutputFormat outputFormat,
/* Missfile-specific DAT info */ /* Missfile-specific DAT info */
@@ -441,7 +445,6 @@ namespace SabreTools
/* Merging and Diffing info */ /* Merging and Diffing info */
bool merge, bool merge,
DiffMode diffMode, DiffMode diffMode,
bool? cascade,
bool inplace, bool inplace,
bool skip, bool skip,
bool bare, bool bare,
@@ -600,6 +603,7 @@ namespace SabreTools
ForceNodump = fn, ForceNodump = fn,
ForcePacking = fp, ForcePacking = fp,
MergeRoms = dedup, MergeRoms = dedup,
ExcludeOf = excludeOf,
OutputFormat = outputFormat, OutputFormat = outputFormat,
UseGame = usegame, UseGame = usegame,
@@ -614,7 +618,7 @@ namespace SabreTools
XSV = tsv, XSV = tsv,
}; };
userInputDat.Update(inputs, outDir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist, userInputDat.Update(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, _logger);
} }

View File

@@ -66,6 +66,7 @@ namespace SabreTools
datPrefix = false, datPrefix = false,
dedup = false, dedup = false,
enableGzip = false, enableGzip = false,
excludeOf = false,
inplace = false, inplace = false,
merge = false, merge = false,
noMD5 = false, noMD5 = false,
@@ -85,8 +86,7 @@ namespace SabreTools
trim = false, trim = false,
skip = false, skip = false,
usegame = true; usegame = true;
bool? cascade = null, bool? tsv = null;
tsv = null;
DiffMode diffMode = 0x0; DiffMode diffMode = 0x0;
int maxParallelism = 4; int maxParallelism = 4;
long sgt = -1, long sgt = -1,
@@ -94,9 +94,9 @@ namespace SabreTools
seq = -1; seq = -1;
OutputFormat outputFormat = 0x0; OutputFormat outputFormat = 0x0;
StatOutputFormat statOutputFormat = StatOutputFormat.None; StatOutputFormat statOutputFormat = StatOutputFormat.None;
string
// DAT fields // DAT fields
string
author = null, author = null,
category = null, category = null,
comment = null, comment = null,
@@ -131,8 +131,8 @@ namespace SabreTools
repext = "", repext = "",
// Misc fields // Misc fields
exta = "", exta = null,
extb = "", extb = null,
outDir = "", outDir = "",
tempDir = ""; tempDir = "";
@@ -166,7 +166,7 @@ namespace SabreTools
break; break;
case "-c": case "-c":
case "--cascade": case "--cascade":
cascade = true; diffMode |= DiffMode.Cascade;
break; break;
case "-cf": case "-cf":
case "--copy-files": case "--copy-files":
@@ -308,7 +308,7 @@ namespace SabreTools
break; break;
case "-rc": case "-rc":
case "--rev-cascade": case "--rev-cascade":
cascade = false; diffMode |= DiffMode.ReverseCascade;
break; break;
case "-re": case "-re":
case "--restore": case "--restore":
@@ -359,6 +359,10 @@ namespace SabreTools
case "--update": case "--update":
update = true; update = true;
break; break;
case "-xof":
case "--exclude-of":
excludeOf = true;
break;
default: default:
string temparg = arg.Replace("\"", "").Replace("file://", ""); string temparg = arg.Replace("\"", "").Replace("file://", "");
@@ -569,6 +573,7 @@ namespace SabreTools
version, version,
author, author,
forcepack, forcepack,
excludeOf,
outputFormat, outputFormat,
romba, romba,
superdat, superdat,
@@ -619,8 +624,8 @@ namespace SabreTools
else if (update || tsv != null || outputFormat != 0 || merge || diffMode != 0) else if (update || tsv != null || outputFormat != 0 || merge || diffMode != 0)
{ {
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header, InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix, superdat, forcemerge, forcend, forcepack, excludeOf, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datPrefix, romba, tsv, merge, diffMode, cascade, inplace, skip, removeDateFromAutomaticName, gamename, romname, postfix, quotes, repext, addext, remext, datPrefix, romba, tsv, merge, diffMode, inplace, skip, removeDateFromAutomaticName, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism); romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism);
} }