[ALL] Add new output formats, add outputformat flag

This commit is contained in:
Matt Nadareski
2016-09-09 14:28:00 -07:00
parent c66ba49f22
commit 5053ee6a42
6 changed files with 110 additions and 71 deletions

View File

@@ -187,8 +187,11 @@ namespace SabreTools.Helper
helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)"); helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)");
helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format"); helptext.Add(" -tsv, --tsv Output in Tab-Separated Value format");
helptext.Add(" -csv, --csv Output in Comma-Separated Value format"); helptext.Add(" -csv, --csv Output in Comma-Separated Value format");
helptext.Add(" -omd5, --output-md5 Output in MD5 format");
helptext.Add(" -or, --output-rc Output in RomCenter format"); helptext.Add(" -or, --output-rc Output in RomCenter format");
helptext.Add(" -os, --output-sd Output in SabreDAT format"); helptext.Add(" -os, --output-sd Output in SabreDAT format");
helptext.Add(" -osfv, --ouput-sfv Output in SFV format");
helptext.Add(" -osha1, --output-sha1 Output in SHA-1 format");
helptext.Add(" -ox, --output-xml Output in Logiqx XML format"); helptext.Add(" -ox, --output-xml Output in Logiqx XML format");
helptext.Add(" -f=, --filename= Set a new filename"); helptext.Add(" -f=, --filename= Set a new filename");
helptext.Add(" -n=, --name= Set a new internal name"); helptext.Add(" -n=, --name= Set a new internal name");

View File

@@ -1,6 +1,4 @@
using System; namespace SabreTools.Helper
namespace SabreTools.Helper
{ {
/// <summary> /// <summary>
/// Possible DAT import classes /// Possible DAT import classes
@@ -164,18 +162,6 @@ namespace SabreTools.Helper
Greater, Greater,
} }
/// <summary>
/// Determines which diffs should be created
/// </summary>
[Flags]
public enum DiffMode
{
Dupes = 0x01,
NoDupes = 0x02,
Individuals = 0x04,
All = Dupes | NoDupes | Individuals,
}
/// <summary> /// <summary>
/// Determines which fields should be split on /// Determines which fields should be split on
/// </summary> /// </summary>

View File

@@ -0,0 +1,33 @@
using System;
namespace SabreTools.Helper
{
/// <summary>
/// Determines which diffs should be created
/// </summary>
[Flags]
public enum DiffMode
{
Dupes = 0x01,
NoDupes = 0x02,
Individuals = 0x04,
All = Dupes | NoDupes | Individuals,
}
/// <summary>
/// Determines the DAT output format
/// </summary>
[Flags]
public enum OutputFormatFlag
{
Xml = 0x001,
ClrMamePro = 0x002,
RomCenter = 0x004,
DOSCenter = 0x008,
MissFile = 0x010,
SabreDat = 0x020,
RedumpMD5 = 0x040,
RedumpSHA1 = 0x080,
RedumpSFV = 0x100,
}
}

View File

@@ -85,6 +85,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Data\Constants.cs" /> <Compile Include="Data\Constants.cs" />
<Compile Include="Data\Flags.cs" />
<Compile Include="External\OptimizedCRC.cs" /> <Compile Include="External\OptimizedCRC.cs" />
<Compile Include="Objects\DATFromDir.cs" /> <Compile Include="Objects\DATFromDir.cs" />
<Compile Include="Objects\DATFromDirParallel.cs" /> <Compile Include="Objects\DATFromDirParallel.cs" />

View File

@@ -93,11 +93,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="outputCMP">True to output to ClrMamePro format</param> /// <param name="outputFormatFlag">Non-zero flag for output format, zero otherwise</param>
/// <param name="outputMiss">True to output to Missfile format</param>
/// <param name="outputRC">True to output to RomCenter format</param>
/// <param name="outputSD">True to output to SabreDAT format</param>
/// <param name="outputXML">True to output to Logiqx XML format</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>
/// <param name="prefix">Generic prefix to be added to each line</param> /// <param name="prefix">Generic prefix to be added to each line</param>
@@ -110,7 +106,7 @@ namespace SabreTools
/// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param> /// <param name="tsv">True to output files in TSV format, false to output files in CSV format, null otherwise</param>
/// /* 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">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="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>
@@ -156,11 +152,7 @@ namespace SabreTools
string forcemerge, string forcemerge,
string forcend, string forcend,
string forcepack, string forcepack,
bool outputCMP, OutputFormatFlag outputFormatFlag,
bool outputMiss,
bool outputRC,
bool outputSD,
bool outputXML,
/* Missfile-specific DAT info */ /* Missfile-specific DAT info */
bool usegame, bool usegame,
@@ -175,7 +167,7 @@ namespace SabreTools
/* Merging and Diffing info */ /* Merging and Diffing info */
bool merge, bool merge,
DiffMode diff, DiffMode diffMode,
bool? cascade, bool? cascade,
bool inplace, bool inplace,
bool skip, bool skip,
@@ -261,7 +253,7 @@ namespace SabreTools
repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext); repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext);
// If we're in merge or diff mode and the names aren't set, set defaults // If we're in merge or diff mode and the names aren't set, set defaults
if (merge || diff != 0) if (merge || diffMode != 0)
{ {
// Get the values that will be used // Get the values that will be used
if (date == "") if (date == "")
@@ -270,17 +262,17 @@ namespace SabreTools
} }
if (name == "") if (name == "")
{ {
name = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : ""); name = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : "");
} }
if (description == "") if (description == "")
{ {
description = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : ""); description = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : "");
if (!bare) if (!bare)
{ {
description += " (" + date + ")"; description += " (" + date + ")";
} }
} }
if (category == "" && diff != 0) if (category == "" && diffMode != 0)
{ {
category = "DiffDAT"; category = "DiffDAT";
} }
@@ -323,39 +315,57 @@ namespace SabreTools
XSV = tsv, XSV = tsv,
}; };
if (outputCMP) if ((outputFormatFlag & OutputFormatFlag.ClrMamePro) != 0)
{ {
userInputDat.OutputFormat = OutputFormat.ClrMamePro; userInputDat.OutputFormat = OutputFormat.ClrMamePro;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
if (outputMiss || tsv != null) if ((outputFormatFlag & OutputFormatFlag.MissFile) != 0 || tsv != null)
{ {
userInputDat.OutputFormat = OutputFormat.MissFile; userInputDat.OutputFormat = OutputFormat.MissFile;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
if (outputRC) if ((outputFormatFlag & OutputFormatFlag.RedumpMD5) != 0)
{
userInputDat.OutputFormat = OutputFormat.RedumpMD5;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
}
if ((outputFormatFlag & OutputFormatFlag.RedumpSFV) != 0)
{
userInputDat.OutputFormat = OutputFormat.RedumpSFV;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
}
if ((outputFormatFlag & OutputFormatFlag.RedumpSHA1) != 0)
{
userInputDat.OutputFormat = OutputFormat.RedumpSHA1;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
}
if ((outputFormatFlag & OutputFormatFlag.RomCenter) != 0)
{ {
userInputDat.OutputFormat = OutputFormat.RomCenter; userInputDat.OutputFormat = OutputFormat.RomCenter;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
if (outputSD) if ((outputFormatFlag & OutputFormatFlag.SabreDat) != 0)
{ {
userInputDat.OutputFormat = OutputFormat.SabreDat; userInputDat.OutputFormat = OutputFormat.SabreDat;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
if (outputXML) if ((outputFormatFlag & OutputFormatFlag.Xml) != 0)
{ {
userInputDat.OutputFormat = OutputFormat.Xml; userInputDat.OutputFormat = OutputFormat.Xml;
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
if (!outputCMP && !(outputMiss || tsv != null) && !outputRC && !outputSD && !outputXML) if (outputFormatFlag == 0 && tsv == null)
{ {
DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diff, cascade, inplace, skip, bare, clean, softlist, DatTools.UpdateParallel(inputs, userInputDat, outdir, merge, diffMode, cascade, inplace, skip, bare, clean, softlist,
gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger); gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, maxDegreeOfParallelism, _logger);
} }
} }

View File

@@ -105,11 +105,6 @@ namespace SabreTools
noSHA1 = false, noSHA1 = false,
offlineMerge = false, offlineMerge = false,
old = false, old = false,
outputCMP = false,
outputMiss = false,
outputRC = false,
outputSD = false,
outputXML = false,
quotes = false, quotes = false,
rem = false, rem = false,
romba = false, romba = false,
@@ -125,11 +120,12 @@ namespace SabreTools
bool? cascade = null, bool? cascade = null,
nodump = null, nodump = null,
tsv = null; tsv = null;
DiffMode diff = 0x0; DiffMode diffMode = 0x0;
int maxParallelism = -1; int maxParallelism = -1;
long sgt = -1, long sgt = -1,
slt = -1, slt = -1,
seq = -1; seq = -1;
OutputFormatFlag outputFormatFlag = 0x0;
string addext = "", string addext = "",
author = "", author = "",
category = "", category = "",
@@ -193,19 +189,19 @@ namespace SabreTools
break; break;
case "-cc": case "-cc":
case "--convert-cmp": case "--convert-cmp":
outputCMP = true; outputFormatFlag |= OutputFormatFlag.ClrMamePro;
break; break;
case "-cm": case "-cm":
case "--convert-miss": case "--convert-miss":
outputMiss = true; outputFormatFlag |= OutputFormatFlag.MissFile;
break; break;
case "-cr": case "-cr":
case "--convert-rc": case "--convert-rc":
outputRC = true; outputFormatFlag |= OutputFormatFlag.RomCenter;
break; break;
case "-cs": case "-cs":
case "--convert-sd": case "--convert-sd":
outputSD = true; outputFormatFlag |= OutputFormatFlag.SabreDat;
break; break;
case "-csv": case "-csv":
case "--csv": case "--csv":
@@ -213,7 +209,7 @@ namespace SabreTools
break; break;
case "-cx": case "-cx":
case "--convert-xml": case "--convert-xml":
outputXML = true; outputFormatFlag |= OutputFormatFlag.Xml;
break; break;
case "-clean": case "-clean":
case "--clean": case "--clean":
@@ -230,19 +226,19 @@ namespace SabreTools
break; break;
case "-di": case "-di":
case "--diff": case "--diff":
diff |= DiffMode.All; diffMode |= DiffMode.All;
break; break;
case "-did": case "-did":
case "--diff-du": case "--diff-du":
diff |= DiffMode.Dupes; diffMode |= DiffMode.Dupes;
break; break;
case "-dii": case "-dii":
case "--diff-in": case "--diff-in":
diff |= DiffMode.Individuals; diffMode |= DiffMode.Individuals;
break; break;
case "-din": case "-din":
case "--diff-nd": case "--diff-nd":
diff |= DiffMode.NoDupes; diffMode |= DiffMode.NoDupes;
break; break;
case "-dp": case "-dp":
case "--d2dp": case "--d2dp":
@@ -331,7 +327,7 @@ namespace SabreTools
break; break;
case "-oc": case "-oc":
case "--output-cmp": case "--output-cmp":
outputCMP = true; outputFormatFlag |= OutputFormatFlag.ClrMamePro;
break; break;
case "-ol": case "-ol":
case "--offmerge": case "--offmerge":
@@ -339,19 +335,31 @@ namespace SabreTools
break; break;
case "-om": case "-om":
case "--output-miss": case "--output-miss":
outputMiss = true; outputFormatFlag |= OutputFormatFlag.MissFile;
break;
case "-omd5":
case "--output-md5":
outputFormatFlag |= OutputFormatFlag.RedumpMD5;
break; break;
case "-or": case "-or":
case "--output-rc": case "--output-rc":
outputRC = true; outputFormatFlag |= OutputFormatFlag.RomCenter;
break; break;
case "-os": case "-os":
case "--output-sd": case "--output-sd":
outputSD = true; outputFormatFlag |= OutputFormatFlag.SabreDat;
break;
case "-osfv":
case "--output-sfv":
outputFormatFlag |= OutputFormatFlag.RedumpSFV;
break;
case "-osha1":
case "--output-sha1":
outputFormatFlag |= OutputFormatFlag.RedumpSHA1;
break; break;
case "-ox": case "-ox":
case "--output-xml": case "--output-xml":
outputXML = true; outputFormatFlag |= OutputFormatFlag.Xml;
break; break;
case "-q": case "-q":
case "--quotes": case "--quotes":
@@ -615,8 +623,7 @@ namespace SabreTools
// If more than one switch is enabled, show the help screen // If more than one switch is enabled, show the help screen
if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^ if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^
(merge || diff != 0 || update || outputCMP || outputRC || outputSD || outputXML || outputMiss || tsv != null|| trim) ^ (merge || diffMode != 0 || update || outputFormatFlag != 0 || tsv != null|| trim) ^ offlineMerge ^ rem ^ stats ^ typesplit))
offlineMerge ^ rem ^ stats ^ typesplit))
{ {
_logger.Error("Only one feature switch is allowed at a time"); _logger.Error("Only one feature switch is allowed at a time");
Build.Help(); Build.Help();
@@ -625,9 +632,8 @@ namespace SabreTools
} }
// If a switch that requires a filename is set and no file is, show the help screen // 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 if (inputs.Count == 0 && (update || outputFormatFlag != 0 || tsv != null || extsplit || hashsplit || datfromdir
|| outputXML || extsplit || hashsplit || datfromdir || datfromdirparallel || (merge || diff != 0) || datfromdirparallel || (merge || diffMode != 0) || stats || trim || typesplit))
|| stats || trim || typesplit))
{ {
_logger.Error("This feature requires at least one input"); _logger.Error("This feature requires at least one input");
Build.Help(); Build.Help();
@@ -670,11 +676,11 @@ namespace SabreTools
} }
// Convert, update, merge, diff, and filter a DAT or folder of DATs // Convert, update, merge, diff, and filter a DAT or folder of DATs
else if (update || outputCMP || outputMiss || tsv != null || outputRC || outputSD || outputXML || merge || diff != 0) else if (update || tsv != null || outputFormatFlag != 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, outputCMP, outputMiss, outputRC, outputSD, outputXML, usegame, prefix, superdat, forcemerge, forcend, forcepack, outputFormatFlag, usegame, prefix,
postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diff, cascade, inplace, skip, bare, gamename, romname, postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diffMode, cascade, inplace, skip, bare, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism); romtype, sgt, slt, seq, crc, md5, sha1, nodump, trim, single, root, outdir, clean, softlist, dedup, maxParallelism);
} }