mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ALL] Add new output formats, add outputformat flag
This commit is contained in:
@@ -187,8 +187,11 @@ namespace SabreTools.Helper
|
||||
helptext.Add(" -ro, --romba Output in Romba format (requires SHA-1)");
|
||||
helptext.Add(" -tsv, --tsv Output in Tab-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(" -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(" -f=, --filename= Set a new filename");
|
||||
helptext.Add(" -n=, --name= Set a new internal name");
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace SabreTools.Helper
|
||||
namespace SabreTools.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// Possible DAT import classes
|
||||
@@ -164,18 +162,6 @@ namespace SabreTools.Helper
|
||||
Greater,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which diffs should be created
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DiffMode
|
||||
{
|
||||
Dupes = 0x01,
|
||||
NoDupes = 0x02,
|
||||
Individuals = 0x04,
|
||||
All = Dupes | NoDupes | Individuals,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines which fields should be split on
|
||||
/// </summary>
|
||||
|
||||
33
SabreTools.Helper/Data/Flags.cs
Normal file
33
SabreTools.Helper/Data/Flags.cs
Normal 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,
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Data\Constants.cs" />
|
||||
<Compile Include="Data\Flags.cs" />
|
||||
<Compile Include="External\OptimizedCRC.cs" />
|
||||
<Compile Include="Objects\DATFromDir.cs" />
|
||||
<Compile Include="Objects\DATFromDirParallel.cs" />
|
||||
|
||||
@@ -93,11 +93,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="outputCMP">True to output to ClrMamePro format</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>
|
||||
/// <param name="outputFormatFlag">Non-zero flag for output format, zero otherwise</param>
|
||||
/// /* Missfile-specific DAT info */
|
||||
/// <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>
|
||||
@@ -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>
|
||||
/// /* Merging and Diffing info */
|
||||
/// <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="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>
|
||||
@@ -156,11 +152,7 @@ namespace SabreTools
|
||||
string forcemerge,
|
||||
string forcend,
|
||||
string forcepack,
|
||||
bool outputCMP,
|
||||
bool outputMiss,
|
||||
bool outputRC,
|
||||
bool outputSD,
|
||||
bool outputXML,
|
||||
OutputFormatFlag outputFormatFlag,
|
||||
|
||||
/* Missfile-specific DAT info */
|
||||
bool usegame,
|
||||
@@ -175,7 +167,7 @@ namespace SabreTools
|
||||
|
||||
/* Merging and Diffing info */
|
||||
bool merge,
|
||||
DiffMode diff,
|
||||
DiffMode diffMode,
|
||||
bool? cascade,
|
||||
bool inplace,
|
||||
bool skip,
|
||||
@@ -261,7 +253,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 != 0)
|
||||
if (merge || diffMode != 0)
|
||||
{
|
||||
// Get the values that will be used
|
||||
if (date == "")
|
||||
@@ -270,17 +262,17 @@ namespace SabreTools
|
||||
}
|
||||
if (name == "")
|
||||
{
|
||||
name = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : "");
|
||||
name = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? "-deduped" : "");
|
||||
}
|
||||
if (description == "")
|
||||
{
|
||||
description = (diff != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : "");
|
||||
description = (diffMode != 0 ? "DiffDAT" : "MergeDAT") + (superdat ? "-SuperDAT" : "") + (dedup ? " - deduped" : "");
|
||||
if (!bare)
|
||||
{
|
||||
description += " (" + date + ")";
|
||||
}
|
||||
}
|
||||
if (category == "" && diff != 0)
|
||||
if (category == "" && diffMode != 0)
|
||||
{
|
||||
category = "DiffDAT";
|
||||
}
|
||||
@@ -323,39 +315,57 @@ namespace SabreTools
|
||||
XSV = tsv,
|
||||
};
|
||||
|
||||
if (outputCMP)
|
||||
if ((outputFormatFlag & OutputFormatFlag.ClrMamePro) != 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (outputMiss || tsv != null)
|
||||
if ((outputFormatFlag & OutputFormatFlag.MissFile) != 0 || tsv != null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
if (outputSD)
|
||||
if ((outputFormatFlag & OutputFormatFlag.SabreDat) != 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (outputXML)
|
||||
if ((outputFormatFlag & OutputFormatFlag.Xml) != 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,11 +105,6 @@ namespace SabreTools
|
||||
noSHA1 = false,
|
||||
offlineMerge = false,
|
||||
old = false,
|
||||
outputCMP = false,
|
||||
outputMiss = false,
|
||||
outputRC = false,
|
||||
outputSD = false,
|
||||
outputXML = false,
|
||||
quotes = false,
|
||||
rem = false,
|
||||
romba = false,
|
||||
@@ -125,11 +120,12 @@ namespace SabreTools
|
||||
bool? cascade = null,
|
||||
nodump = null,
|
||||
tsv = null;
|
||||
DiffMode diff = 0x0;
|
||||
DiffMode diffMode = 0x0;
|
||||
int maxParallelism = -1;
|
||||
long sgt = -1,
|
||||
slt = -1,
|
||||
seq = -1;
|
||||
OutputFormatFlag outputFormatFlag = 0x0;
|
||||
string addext = "",
|
||||
author = "",
|
||||
category = "",
|
||||
@@ -193,19 +189,19 @@ namespace SabreTools
|
||||
break;
|
||||
case "-cc":
|
||||
case "--convert-cmp":
|
||||
outputCMP = true;
|
||||
outputFormatFlag |= OutputFormatFlag.ClrMamePro;
|
||||
break;
|
||||
case "-cm":
|
||||
case "--convert-miss":
|
||||
outputMiss = true;
|
||||
outputFormatFlag |= OutputFormatFlag.MissFile;
|
||||
break;
|
||||
case "-cr":
|
||||
case "--convert-rc":
|
||||
outputRC = true;
|
||||
outputFormatFlag |= OutputFormatFlag.RomCenter;
|
||||
break;
|
||||
case "-cs":
|
||||
case "--convert-sd":
|
||||
outputSD = true;
|
||||
outputFormatFlag |= OutputFormatFlag.SabreDat;
|
||||
break;
|
||||
case "-csv":
|
||||
case "--csv":
|
||||
@@ -213,7 +209,7 @@ namespace SabreTools
|
||||
break;
|
||||
case "-cx":
|
||||
case "--convert-xml":
|
||||
outputXML = true;
|
||||
outputFormatFlag |= OutputFormatFlag.Xml;
|
||||
break;
|
||||
case "-clean":
|
||||
case "--clean":
|
||||
@@ -230,19 +226,19 @@ namespace SabreTools
|
||||
break;
|
||||
case "-di":
|
||||
case "--diff":
|
||||
diff |= DiffMode.All;
|
||||
diffMode |= DiffMode.All;
|
||||
break;
|
||||
case "-did":
|
||||
case "--diff-du":
|
||||
diff |= DiffMode.Dupes;
|
||||
diffMode |= DiffMode.Dupes;
|
||||
break;
|
||||
case "-dii":
|
||||
case "--diff-in":
|
||||
diff |= DiffMode.Individuals;
|
||||
diffMode |= DiffMode.Individuals;
|
||||
break;
|
||||
case "-din":
|
||||
case "--diff-nd":
|
||||
diff |= DiffMode.NoDupes;
|
||||
diffMode |= DiffMode.NoDupes;
|
||||
break;
|
||||
case "-dp":
|
||||
case "--d2dp":
|
||||
@@ -331,7 +327,7 @@ namespace SabreTools
|
||||
break;
|
||||
case "-oc":
|
||||
case "--output-cmp":
|
||||
outputCMP = true;
|
||||
outputFormatFlag |= OutputFormatFlag.ClrMamePro;
|
||||
break;
|
||||
case "-ol":
|
||||
case "--offmerge":
|
||||
@@ -339,19 +335,31 @@ namespace SabreTools
|
||||
break;
|
||||
case "-om":
|
||||
case "--output-miss":
|
||||
outputMiss = true;
|
||||
outputFormatFlag |= OutputFormatFlag.MissFile;
|
||||
break;
|
||||
case "-omd5":
|
||||
case "--output-md5":
|
||||
outputFormatFlag |= OutputFormatFlag.RedumpMD5;
|
||||
break;
|
||||
case "-or":
|
||||
case "--output-rc":
|
||||
outputRC = true;
|
||||
outputFormatFlag |= OutputFormatFlag.RomCenter;
|
||||
break;
|
||||
case "-os":
|
||||
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;
|
||||
case "-ox":
|
||||
case "--output-xml":
|
||||
outputXML = true;
|
||||
outputFormatFlag |= OutputFormatFlag.Xml;
|
||||
break;
|
||||
case "-q":
|
||||
case "--quotes":
|
||||
@@ -615,8 +623,7 @@ namespace SabreTools
|
||||
|
||||
// If more than one switch is enabled, show the help screen
|
||||
if (!(add ^ datfromdir ^ datfromdirparallel ^ extsplit ^ generate ^ genall ^ hashsplit ^ import ^ listsrc ^ listsys ^
|
||||
(merge || diff != 0 || update || outputCMP || outputRC || outputSD || outputXML || outputMiss || tsv != null|| trim) ^
|
||||
offlineMerge ^ rem ^ stats ^ typesplit))
|
||||
(merge || diffMode != 0 || update || outputFormatFlag != 0 || tsv != null|| trim) ^ offlineMerge ^ rem ^ stats ^ typesplit))
|
||||
{
|
||||
_logger.Error("Only one feature switch is allowed at a time");
|
||||
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 (inputs.Count == 0 && (update || (outputMiss || tsv != null) || outputCMP || outputRC || outputSD
|
||||
|| outputXML || extsplit || hashsplit || datfromdir || datfromdirparallel || (merge || diff != 0)
|
||||
|| stats || trim || typesplit))
|
||||
if (inputs.Count == 0 && (update || outputFormatFlag != 0 || tsv != null || extsplit || hashsplit || datfromdir
|
||||
|| datfromdirparallel || (merge || diffMode != 0) || stats || trim || typesplit))
|
||||
{
|
||||
_logger.Error("This feature requires at least one input");
|
||||
Build.Help();
|
||||
@@ -670,11 +676,11 @@ 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 != 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,
|
||||
superdat, forcemerge, forcend, forcepack, outputCMP, outputMiss, outputRC, outputSD, outputXML, usegame, prefix,
|
||||
postfix, quotes, repext, addext, datprefix, romba, tsv, merge, diff, cascade, inplace, skip, bare, gamename, romname,
|
||||
superdat, forcemerge, forcend, forcepack, outputFormatFlag, usegame, prefix,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user