[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(" -au=, --author= Set the author of the DAT");
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(" -ad, --add-date Output dates for each file parsed");
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(" Supported values are:");
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(" -sl, --softlist Use Software List name instead of description");
helptext.Add(" -trim Trim file names to fit NTFS length");

View File

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

View File

@@ -34,6 +34,7 @@ namespace SabreTools.Helper
private ForceNodump _forceNodump;
private ForcePacking _forcePacking;
private OutputFormat _outputFormat;
private bool _excludeOf;
private bool _mergeRoms;
private SortedDictionary<string, List<DatItem>> _files;
@@ -154,6 +155,11 @@ namespace SabreTools.Helper
get { return _outputFormat; }
set { _outputFormat = value; }
}
public bool ExcludeOf
{
get { return _excludeOf; }
set { _excludeOf = value; }
}
public bool MergeRoms
{
get { return _mergeRoms; }
@@ -567,7 +573,6 @@ namespace SabreTools.Helper
/// <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="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>
/// <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="maxDegreeOfParallelism">Integer representing the maximum amount of parallelization to be used</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,
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 (cascade == false)
if ((diff & DiffMode.ReverseCascade) != 0)
{
newInputFileNames.Reverse();
}
@@ -647,12 +652,12 @@ namespace SabreTools.Helper
crc, md5, sha1, itemStatus, trim, single, root, maxDegreeOfParallelism, logger);
// 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);
}
// 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);
}
@@ -3777,8 +3782,11 @@ namespace SabreTools.Helper
{
case OutputFormat.ClrMamePro:
state += "game (\n\tname \"" + rom.MachineName + "\"\n" +
(String.IsNullOrEmpty(rom.RomOf) ? "" : "\tromof \"" + rom.RomOf + "\"\n") +
(String.IsNullOrEmpty(rom.CloneOf) ? "" : "\tcloneof \"" + rom.CloneOf + "\"\n") +
(ExcludeOf ? "" :
(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" +
(String.IsNullOrEmpty(rom.Year) ? "" : "\tyear " + rom.Year + "\n") +
(String.IsNullOrEmpty(rom.Manufacturer) ? "" : "\tmanufacturer \"" + rom.Manufacturer + "\"\n");
@@ -3789,15 +3797,17 @@ namespace SabreTools.Helper
case OutputFormat.Logiqx:
state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" +
(rom.IsBios ? " isbios=\"yes\"" : "") +
(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())
? ""
: " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") +
(String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant())
? ""
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"") +
(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())
? ""
: " romof=\"" + HttpUtility.HtmlEncode(rom.RomOf) + "\"") +
(String.IsNullOrEmpty(rom.SampleOf) || (rom.MachineName.ToLowerInvariant() == rom.SampleOf.ToLowerInvariant())
? ""
: " sampleof=\"" + HttpUtility.HtmlEncode(rom.SampleOf) + "\"")
) +
">\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" +

View File

@@ -227,6 +227,10 @@ Options:
Set the type flag to "SuperDAT" for the output DAT as well as preserving the
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
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
@@ -510,6 +514,10 @@ Options:
Set the forcepacking flag to one of the supported values:
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
Game names will be santitized to remove what the original WoD standards
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="version">New version</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="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>
@@ -81,6 +82,7 @@ namespace SabreTools
string version,
string author,
string forcepack,
bool excludeOf,
OutputFormat outputFormat,
bool romba,
bool superdat,
@@ -124,6 +126,7 @@ namespace SabreTools
ForcePacking = fp,
OutputFormat = (outputFormat == 0 ? OutputFormat.Logiqx : outputFormat),
Romba = romba,
ExcludeOf = excludeOf,
Type = (superdat ? "SuperDAT" : ""),
Files = new SortedDictionary<string, List<DatItem>>(),
};
@@ -364,6 +367,7 @@ namespace SabreTools
/// <param name="forcemerge">None, Split, Full</param>
/// <param name="forcend">None, Obsolete, Required, Ignore</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>
/// /* Missfile-specific DAT info */
/// <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 */
/// <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="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>
/// <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 forcend,
string forcepack,
bool excludeOf,
OutputFormat outputFormat,
/* Missfile-specific DAT info */
@@ -441,7 +445,6 @@ namespace SabreTools
/* Merging and Diffing info */
bool merge,
DiffMode diffMode,
bool? cascade,
bool inplace,
bool skip,
bool bare,
@@ -600,6 +603,7 @@ namespace SabreTools
ForceNodump = fn,
ForcePacking = fp,
MergeRoms = dedup,
ExcludeOf = excludeOf,
OutputFormat = outputFormat,
UseGame = usegame,
@@ -614,7 +618,7 @@ namespace SabreTools
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);
}

View File

@@ -66,6 +66,7 @@ namespace SabreTools
datPrefix = false,
dedup = false,
enableGzip = false,
excludeOf = false,
inplace = false,
merge = false,
noMD5 = false,
@@ -85,8 +86,7 @@ namespace SabreTools
trim = false,
skip = false,
usegame = true;
bool? cascade = null,
tsv = null;
bool? tsv = null;
DiffMode diffMode = 0x0;
int maxParallelism = 4;
long sgt = -1,
@@ -94,9 +94,9 @@ namespace SabreTools
seq = -1;
OutputFormat outputFormat = 0x0;
StatOutputFormat statOutputFormat = StatOutputFormat.None;
string
// DAT fields
// DAT fields
string
author = null,
category = null,
comment = null,
@@ -131,8 +131,8 @@ namespace SabreTools
repext = "",
// Misc fields
exta = "",
extb = "",
exta = null,
extb = null,
outDir = "",
tempDir = "";
@@ -166,7 +166,7 @@ namespace SabreTools
break;
case "-c":
case "--cascade":
cascade = true;
diffMode |= DiffMode.Cascade;
break;
case "-cf":
case "--copy-files":
@@ -308,7 +308,7 @@ namespace SabreTools
break;
case "-rc":
case "--rev-cascade":
cascade = false;
diffMode |= DiffMode.ReverseCascade;
break;
case "-re":
case "--restore":
@@ -359,6 +359,10 @@ namespace SabreTools
case "--update":
update = true;
break;
case "-xof":
case "--exclude-of":
excludeOf = true;
break;
default:
string temparg = arg.Replace("\"", "").Replace("file://", "");
@@ -569,6 +573,7 @@ namespace SabreTools
version,
author,
forcepack,
excludeOf,
outputFormat,
romba,
superdat,
@@ -619,8 +624,8 @@ namespace SabreTools
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,
superdat, forcemerge, forcend, forcepack, outputFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datPrefix, romba, tsv, merge, diffMode, cascade, inplace, skip, removeDateFromAutomaticName, gamename, romname,
superdat, forcemerge, forcend, forcepack, excludeOf, outputFormat, usegame, prefix,
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);
}