[SabreTools, Flags, DatFile, Utilities] Add SSV in/out

This commit is contained in:
Matt Nadareski
2018-01-08 18:02:50 -08:00
parent c4bacd67c3
commit f366e32c48
6 changed files with 67 additions and 5 deletions

View File

@@ -2347,7 +2347,9 @@ namespace SabreTools.Library.DatFiles
DatFile innerDatdata = new DatFile(this);
Globals.Logger.User("Processing '{0}'", Path.GetFileName(file.Split('¬')[0]));
innerDatdata.Parse(file, 0, 0, splitType, keep: true, clean: clean, remUnicode: remUnicode, descAsName: descAsName,
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0 || (innerDatdata.DatFormat & DatFormat.CSV) != 0));
keepext: ((innerDatdata.DatFormat & DatFormat.TSV) != 0
|| (innerDatdata.DatFormat & DatFormat.CSV) != 0
|| (innerDatdata.DatFormat & DatFormat.SSV) != 0));
filter.FilterDatFile(innerDatdata);
// Get the correct output path
@@ -5793,6 +5795,12 @@ namespace SabreTools.Library.DatFiles
outfileNames.Add(DatFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", overwrite));
}
// SSV
if ((DatFormat & DatFormat.SSV) != 0)
{
outfileNames.Add(DatFormat.SSV, CreateOutfileNamesHelper(outDir, ".ssv", overwrite));
};
// TSV
if ((DatFormat & DatFormat.TSV) != 0)
{

View File

@@ -206,8 +206,9 @@ namespace SabreTools.Library.Data
// Standardized Text Formats
MissFile = AttractMode << 1,
CSV = MissFile << 1,
TSV = CSV << 1,
CSV = MissFile << 1, // Comma-separated
SSV = CSV << 1, // Semicolon-separated
TSV = SSV << 1, // Tab-separated
Listrom = TSV << 1,
// SFV-similar Formats

View File

@@ -256,7 +256,10 @@ Options:
-osl, --output-softwarelist Output in Software List format
Add outputting the created DAT to Software List XML format
-ossv, --output-ssv Output in Semicolon-Separated Value format
Add outputting the created DAT to standardized SSV format
-otsv, --output-tsv Output in Tab-Separated Value format
Add outputting the created DAT to standardized TSV format
@@ -467,7 +470,10 @@ Options:
-osl, --output-softwarelist Output in Software List format
Add outputting the created DAT to Software List XML format
-ossv, --output-ssv Output in Semicolon-Separated Value format
Add outputting the created DAT to standardized SSV format
-otsv, --output-tsv Output in Tab-Separated Value format
Add outputting the created DAT to standardized TSV format
@@ -922,7 +928,30 @@ Options:
-osl, --output-softwarelist Output in Software List format
Add outputting the created DAT to Software List XML format
-ossv, --output-ssv Output in Semicolon-Separated Value format
Add outputting the created DAT to standardized SSV format
-pre=, --prefix= Set prefix for all lines
Set a generic prefix to be prepended to all outputted lines
-post=, --postfix= Set postfix for all lines
Set a generic postfix to be appended to all outputted lines
Both prefix and postfix can use one of the following strings:
- %game% - Replaced with the Game/Machine name
- %name% - Replaced with the Rom name
- %crc% - Replaced with the CRC
- %md5% - Replaced with the MD5
- %sha1% - Replaced with the SHA-1
- %sha256% - Replaced with the SHA-256
- %sha384% - Replaced with the SHA-384
- %sha512% - Replaced with the SHA-512
- %size% - Replaced with the size
-q, --quotes Put double-quotes around each item
This quotes only the item and not the prefix and postfix
-otsv, --output-tsv Output in Tab-Separated Value format
Add outputting the created DAT to standardized TSV format

View File

@@ -619,6 +619,8 @@ namespace SabreTools.Library.Tools
return new SabreDat(baseDat);
case DatFormat.SoftwareList:
return new SoftwareList(baseDat);
case DatFormat.SSV:
return new DatFiles.SeparatedValue(baseDat, ';');
case DatFormat.TSV:
return new DatFiles.SeparatedValue(baseDat, '\t');
}
@@ -1035,6 +1037,8 @@ namespace SabreTools.Library.Tools
return DatFormat.RedumpSHA384;
case "sha512":
return DatFormat.RedumpSHA512;
case "ssv":
return DatFormat.SSV;
case "tsv":
return DatFormat.TSV;
}

View File

@@ -687,6 +687,17 @@ namespace SabreTools
null);
}
}
private static Feature outputSsvFlag
{
get
{
return new Feature(
new List<string>() { "-ossv", "--output-ssv" },
"Output in SSV format",
FeatureType.Flag,
null);
}
}
private static Feature outputTsvFlag
{
get
@@ -1992,6 +2003,7 @@ namespace SabreTools
datFromDir.AddFeature("output-sha384", outputSha384Flag);
datFromDir.AddFeature("output-sha512", outputSha512Flag);
datFromDir.AddFeature("output-softwarelist", outputSoftwarelistFlag);
datFromDir.AddFeature("output-ssv", outputSsvFlag);
datFromDir.AddFeature("output-tsv", outputTsvFlag);
datFromDir.AddFeature("output-xml", outputXmlFlag);
datFromDir.AddFeature("romba", rombaFlag);
@@ -2117,6 +2129,7 @@ namespace SabreTools
split.AddFeature("output-sha384", outputSha384Flag);
split.AddFeature("output-sha512", outputSha512Flag);
split.AddFeature("output-softwarelist", outputSoftwarelistFlag);
split.AddFeature("output-ssv", outputSsvFlag);
split.AddFeature("output-tsv", outputTsvFlag);
split.AddFeature("output-xml", outputXmlFlag);
split.AddFeature("output-dir", outputDirStringInput);
@@ -2209,6 +2222,10 @@ namespace SabreTools
update.AddFeature("output-sha512", outputSha512Flag);
update["output-sha512"].AddFeature("game-prefix", gamePrefixFlag);
update.AddFeature("output-softwarelist", outputSoftwarelistFlag);
update.AddFeature("output-ssv", outputSsvFlag);
update["output-ssv"].AddFeature("prefix", prefixStringInput);
update["output-ssv"].AddFeature("postfix", postfixStringInput);
update["output-ssv"].AddFeature("quotes", quotesFlag);
update.AddFeature("output-tsv", outputTsvFlag);
update["output-tsv"].AddFeature("prefix", prefixStringInput);
update["output-tsv"].AddFeature("postfix", postfixStringInput);

View File

@@ -366,6 +366,9 @@ namespace SabreTools
case "output-softwarelist":
datHeader.DatFormat |= DatFormat.SoftwareList;
break;
case "output-ssv":
datHeader.DatFormat |= DatFormat.SSV;
break;
case "output-tsv":
datHeader.DatFormat |= DatFormat.TSV;
break;