[ALL] Rename OutputFormat => DatFormat

This commit is contained in:
Matt Nadareski
2016-10-25 15:02:02 -07:00
parent b85d2df0ca
commit 521b2c77a8
9 changed files with 286 additions and 280 deletions

View File

@@ -254,7 +254,7 @@ namespace SabreTools
FileName = Path.GetFileName(inputs[0]) + " Dir2Dat",
Name = Path.GetFileName(inputs[0]) + " Dir2Dat",
Description = Path.GetFileName(inputs[0]) + " Dir2Dat",
OutputFormat = OutputFormat.Logiqx,
DatFormat = DatFormat.Logiqx,
Files = new SortedDictionary<string, List<DatItem>>(),
};

View File

@@ -353,6 +353,12 @@ namespace SabreTools.Helper.Data
helptext.Add(" -h=, --header= Set a header skipper to use, blank means all");
// Additional Notes
helptext.Add("");
helptext.Add("Archive scanning levels:");
helptext.Add(" 0 Hash archive and contents");
helptext.Add(" 1 Only hash contents");
helptext.Add(" 2 Only hash archive");
helptext.Add("");
helptext.Add("Filenames and directories can't start with a reserved string");
helptext.Add("unless prefixed by 'input='");

View File

@@ -188,7 +188,7 @@
/// <summary>
/// Determine which format to output Stats to
/// </summary>
public enum StatOutputFormat
public enum StatDatFormat
{
None = 0,
HTML = 1,

View File

@@ -118,7 +118,7 @@ namespace SabreTools.Helper.Data
/// Determines the DAT output format
/// </summary>
[Flags]
public enum OutputFormat
public enum DatFormat
{
Logiqx = 0x0001,
ClrMamePro = 0x0002,

File diff suppressed because it is too large Load Diff

View File

@@ -51,9 +51,9 @@ namespace SabreTools.Helper.Tools
/// Get what type of DAT the input file is
/// </summary>
/// <param name="filename">Name of the file to be parsed</param>
/// <returns>The OutputFormat corresponding to the DAT</returns>
/// <returns>The DatFormat corresponding to the DAT</returns>
/// <remarks>There is currently no differentiation between XML and SabreDAT here</remarks>
public static OutputFormat GetOutputFormat(string filename, Logger logger)
public static DatFormat GetDatFormat(string filename, Logger logger)
{
// Limit the output formats based on extension
string ext = Path.GetExtension(filename).ToLowerInvariant();
@@ -79,15 +79,15 @@ namespace SabreTools.Helper.Tools
// Some formats only require the extension to know
if (ext == "md5")
{
return OutputFormat.RedumpMD5;
return DatFormat.RedumpMD5;
}
if (ext == "sfv")
{
return OutputFormat.RedumpSFV;
return DatFormat.RedumpSFV;
}
if (ext == "sha1")
{
return OutputFormat.RedumpSHA1;
return DatFormat.RedumpSHA1;
}
// For everything else, we need to read it
@@ -104,49 +104,49 @@ namespace SabreTools.Helper.Tools
{
if (second.StartsWith("<!doctype datafile"))
{
return OutputFormat.Logiqx;
return DatFormat.Logiqx;
}
else if (second.StartsWith("<!doctype softwarelist"))
{
return OutputFormat.SoftwareList;
return DatFormat.SoftwareList;
}
else if (second.StartsWith("<!doctype sabredat"))
{
return OutputFormat.SabreDat;
return DatFormat.SabreDat;
}
else if (second.StartsWith("<dat") && !second.StartsWith("<datafile"))
{
return OutputFormat.OfflineList;
return DatFormat.OfflineList;
}
// Older and non-compliant DATs
else
{
return OutputFormat.Logiqx;
return DatFormat.Logiqx;
}
}
// If we have an INI-based DAT
else if (first.Contains("[") && first.Contains("]"))
{
return OutputFormat.RomCenter;
return DatFormat.RomCenter;
}
// If we have a CMP-based DAT
else if (first.Contains("clrmamepro"))
{
return OutputFormat.ClrMamePro;
return DatFormat.ClrMamePro;
}
else if (first.Contains("romvault"))
{
return OutputFormat.ClrMamePro;
return DatFormat.ClrMamePro;
}
else if (first.Contains("doscenter"))
{
return OutputFormat.DOSCenter;
return DatFormat.DOSCenter;
}
else
{
return OutputFormat.ClrMamePro;
return DatFormat.ClrMamePro;
}
}
catch (Exception)

View File

@@ -25,10 +25,10 @@ namespace SabreTools.Helper.Tools
/// <param name="datdata">DAT information</param>
/// <param name="overwrite">True if we ignore existing files (default), false otherwise</param>
/// <returns>Dictionary of output formats mapped to file names</returns>
public static Dictionary<OutputFormat, string> CreateOutfileNames(string outDir, DatFile datdata, bool overwrite = true)
public static Dictionary<DatFormat, string> CreateOutfileNames(string outDir, DatFile datdata, bool overwrite = true)
{
// Create the output dictionary
Dictionary<OutputFormat, string> outfileNames = new Dictionary<OutputFormat, string>();
Dictionary<DatFormat, string> outfileNames = new Dictionary<DatFormat, string>();
// Double check the outDir for the end delim
if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
@@ -39,117 +39,117 @@ namespace SabreTools.Helper.Tools
// Get the extensions from the output type
// ClrMamePro
if ((datdata.OutputFormat & OutputFormat.ClrMamePro) != 0)
if ((datdata.DatFormat & DatFormat.ClrMamePro) != 0)
{
outfileNames.Add(OutputFormat.ClrMamePro, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
outfileNames.Add(DatFormat.ClrMamePro, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
};
// CSV
if ((datdata.OutputFormat & OutputFormat.CSV) != 0)
if ((datdata.DatFormat & DatFormat.CSV) != 0)
{
outfileNames.Add(OutputFormat.CSV, CreateOutfileNamesHelper(outDir, ".csv", datdata, overwrite));
outfileNames.Add(DatFormat.CSV, CreateOutfileNamesHelper(outDir, ".csv", datdata, overwrite));
};
// DOSCenter
if ((datdata.OutputFormat & OutputFormat.DOSCenter) != 0
&& (datdata.OutputFormat & OutputFormat.ClrMamePro) == 0
&& (datdata.OutputFormat & OutputFormat.RomCenter) == 0)
if ((datdata.DatFormat & DatFormat.DOSCenter) != 0
&& (datdata.DatFormat & DatFormat.ClrMamePro) == 0
&& (datdata.DatFormat & DatFormat.RomCenter) == 0)
{
outfileNames.Add(OutputFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
outfileNames.Add(DatFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
};
if ((datdata.OutputFormat & OutputFormat.DOSCenter) != 0
&& ((datdata.OutputFormat & OutputFormat.ClrMamePro) != 0
|| (datdata.OutputFormat & OutputFormat.RomCenter) != 0))
if ((datdata.DatFormat & DatFormat.DOSCenter) != 0
&& ((datdata.DatFormat & DatFormat.ClrMamePro) != 0
|| (datdata.DatFormat & DatFormat.RomCenter) != 0))
{
outfileNames.Add(OutputFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dc.dat", datdata, overwrite));
outfileNames.Add(DatFormat.DOSCenter, CreateOutfileNamesHelper(outDir, ".dc.dat", datdata, overwrite));
};
// Logiqx XML
if ((datdata.OutputFormat & OutputFormat.Logiqx) != 0)
if ((datdata.DatFormat & DatFormat.Logiqx) != 0)
{
outfileNames.Add(OutputFormat.Logiqx, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
outfileNames.Add(DatFormat.Logiqx, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
};
// Missfile
if ((datdata.OutputFormat & OutputFormat.MissFile) != 0)
if ((datdata.DatFormat & DatFormat.MissFile) != 0)
{
outfileNames.Add(OutputFormat.MissFile, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite));
outfileNames.Add(DatFormat.MissFile, CreateOutfileNamesHelper(outDir, ".txt", datdata, overwrite));
};
// OfflineList
if (((datdata.OutputFormat & OutputFormat.OfflineList) != 0)
&& (datdata.OutputFormat & OutputFormat.Logiqx) == 0
&& (datdata.OutputFormat & OutputFormat.SabreDat) == 0
&& (datdata.OutputFormat & OutputFormat.SoftwareList) == 0)
if (((datdata.DatFormat & DatFormat.OfflineList) != 0)
&& (datdata.DatFormat & DatFormat.Logiqx) == 0
&& (datdata.DatFormat & DatFormat.SabreDat) == 0
&& (datdata.DatFormat & DatFormat.SoftwareList) == 0)
{
outfileNames.Add(OutputFormat.OfflineList, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
outfileNames.Add(DatFormat.OfflineList, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
}
if (((datdata.OutputFormat & OutputFormat.OfflineList) != 0
&& ((datdata.OutputFormat & OutputFormat.Logiqx) != 0
|| (datdata.OutputFormat & OutputFormat.SabreDat) != 0
|| (datdata.OutputFormat & OutputFormat.SoftwareList) != 0)))
if (((datdata.DatFormat & DatFormat.OfflineList) != 0
&& ((datdata.DatFormat & DatFormat.Logiqx) != 0
|| (datdata.DatFormat & DatFormat.SabreDat) != 0
|| (datdata.DatFormat & DatFormat.SoftwareList) != 0)))
{
outfileNames.Add(OutputFormat.OfflineList, CreateOutfileNamesHelper(outDir, ".ol.xml", datdata, overwrite));
outfileNames.Add(DatFormat.OfflineList, CreateOutfileNamesHelper(outDir, ".ol.xml", datdata, overwrite));
}
// Redump MD5
if ((datdata.OutputFormat & OutputFormat.RedumpMD5) != 0)
if ((datdata.DatFormat & DatFormat.RedumpMD5) != 0)
{
outfileNames.Add(OutputFormat.RedumpMD5, CreateOutfileNamesHelper(outDir, ".md5", datdata, overwrite));
outfileNames.Add(DatFormat.RedumpMD5, CreateOutfileNamesHelper(outDir, ".md5", datdata, overwrite));
};
// Redump SFV
if ((datdata.OutputFormat & OutputFormat.RedumpSFV) != 0)
if ((datdata.DatFormat & DatFormat.RedumpSFV) != 0)
{
outfileNames.Add(OutputFormat.RedumpSFV, CreateOutfileNamesHelper(outDir, ".sfv", datdata, overwrite));
outfileNames.Add(DatFormat.RedumpSFV, CreateOutfileNamesHelper(outDir, ".sfv", datdata, overwrite));
};
// Redump SHA-1
if ((datdata.OutputFormat & OutputFormat.RedumpSHA1) != 0)
if ((datdata.DatFormat & DatFormat.RedumpSHA1) != 0)
{
outfileNames.Add(OutputFormat.RedumpSHA1, CreateOutfileNamesHelper(outDir, ".sha1", datdata, overwrite));
outfileNames.Add(DatFormat.RedumpSHA1, CreateOutfileNamesHelper(outDir, ".sha1", datdata, overwrite));
};
// RomCenter
if ((datdata.OutputFormat & OutputFormat.RomCenter) != 0
&& (datdata.OutputFormat & OutputFormat.ClrMamePro) == 0)
if ((datdata.DatFormat & DatFormat.RomCenter) != 0
&& (datdata.DatFormat & DatFormat.ClrMamePro) == 0)
{
outfileNames.Add(OutputFormat.RomCenter, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
outfileNames.Add(DatFormat.RomCenter, CreateOutfileNamesHelper(outDir, ".dat", datdata, overwrite));
};
if ((datdata.OutputFormat & OutputFormat.RomCenter) != 0
&& (datdata.OutputFormat & OutputFormat.ClrMamePro) != 0)
if ((datdata.DatFormat & DatFormat.RomCenter) != 0
&& (datdata.DatFormat & DatFormat.ClrMamePro) != 0)
{
outfileNames.Add(OutputFormat.RomCenter, CreateOutfileNamesHelper(outDir, ".rc.dat", datdata, overwrite));
outfileNames.Add(DatFormat.RomCenter, CreateOutfileNamesHelper(outDir, ".rc.dat", datdata, overwrite));
};
// SabreDAT
if ((datdata.OutputFormat & OutputFormat.SabreDat) != 0 && (datdata.OutputFormat & OutputFormat.Logiqx) == 0)
if ((datdata.DatFormat & DatFormat.SabreDat) != 0 && (datdata.DatFormat & DatFormat.Logiqx) == 0)
{
outfileNames.Add(OutputFormat.SabreDat, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
outfileNames.Add(DatFormat.SabreDat, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
};
if ((datdata.OutputFormat & OutputFormat.SabreDat) != 0 && (datdata.OutputFormat & OutputFormat.Logiqx) != 0)
if ((datdata.DatFormat & DatFormat.SabreDat) != 0 && (datdata.DatFormat & DatFormat.Logiqx) != 0)
{
outfileNames.Add(OutputFormat.SabreDat, CreateOutfileNamesHelper(outDir, ".sd.xml", datdata, overwrite));
outfileNames.Add(DatFormat.SabreDat, CreateOutfileNamesHelper(outDir, ".sd.xml", datdata, overwrite));
};
// Software List
if ((datdata.OutputFormat & OutputFormat.SoftwareList) != 0
&& (datdata.OutputFormat & OutputFormat.Logiqx) == 0
&& (datdata.OutputFormat & OutputFormat.SabreDat) == 0)
if ((datdata.DatFormat & DatFormat.SoftwareList) != 0
&& (datdata.DatFormat & DatFormat.Logiqx) == 0
&& (datdata.DatFormat & DatFormat.SabreDat) == 0)
{
outfileNames.Add(OutputFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
outfileNames.Add(DatFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".xml", datdata, overwrite));
}
if ((datdata.OutputFormat & OutputFormat.SoftwareList) != 0
&& ((datdata.OutputFormat & OutputFormat.Logiqx) != 0
|| (datdata.OutputFormat & OutputFormat.SabreDat) != 0))
if ((datdata.DatFormat & DatFormat.SoftwareList) != 0
&& ((datdata.DatFormat & DatFormat.Logiqx) != 0
|| (datdata.DatFormat & DatFormat.SabreDat) != 0))
{
outfileNames.Add(OutputFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", datdata, overwrite));
outfileNames.Add(DatFormat.SoftwareList, CreateOutfileNamesHelper(outDir, ".sl.xml", datdata, overwrite));
}
// TSV
if ((datdata.OutputFormat & OutputFormat.TSV) != 0)
if ((datdata.DatFormat & DatFormat.TSV) != 0)
{
outfileNames.Add(OutputFormat.TSV, CreateOutfileNamesHelper(outDir, ".tsv", datdata, overwrite));
outfileNames.Add(DatFormat.TSV, CreateOutfileNamesHelper(outDir, ".tsv", datdata, overwrite));
};
return outfileNames;

View File

@@ -79,7 +79,7 @@ namespace SabreTools
/// <param name="author">New author</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="datFormat">DatFormat 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>
/// <param name="noMD5">True to disable getting MD5 hash, false otherwise</param>
@@ -103,7 +103,7 @@ namespace SabreTools
string author,
string forcepack,
bool excludeOf,
OutputFormat outputFormat,
DatFormat datFormat,
bool romba,
bool superdat,
bool noMD5,
@@ -145,7 +145,7 @@ namespace SabreTools
Date = DateTime.Now.ToString("yyyy-MM-dd"),
Author = author,
ForcePacking = fp,
OutputFormat = (outputFormat == 0 ? OutputFormat.Logiqx : outputFormat),
DatFormat = (datFormat == 0 ? DatFormat.Logiqx : datFormat),
Romba = romba,
ExcludeOf = excludeOf,
Type = (superdat ? "SuperDAT" : ""),
@@ -348,10 +348,10 @@ namespace SabreTools
/// <param name="single">True to show individual DAT statistics, false otherwise</param>
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
/// <param name="statOutputFormat">Set the statistics output format to use</param>
private static void InitStats(List<string> inputs, string filename, bool single, bool baddumpCol, bool nodumpCol, StatOutputFormat statOutputFormat)
/// <param name="statDatFormat">Set the statistics output format to use</param>
private static void InitStats(List<string> inputs, string filename, bool single, bool baddumpCol, bool nodumpCol, StatDatFormat statDatFormat)
{
DatFile.OutputStats(inputs, (String.IsNullOrEmpty(filename) ? "report" : filename), single, baddumpCol, nodumpCol, statOutputFormat, _logger);
DatFile.OutputStats(inputs, (String.IsNullOrEmpty(filename) ? "report" : filename), single, baddumpCol, nodumpCol, statDatFormat, _logger);
}
/// <summary>
@@ -412,7 +412,7 @@ namespace SabreTools
/// <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>
/// <param name="datFormat">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>
/// <param name="prefix">Generic prefix to be added to each line</param>
@@ -471,7 +471,7 @@ namespace SabreTools
string forcend,
string forcepack,
bool excludeOf,
OutputFormat outputFormat,
DatFormat datFormat,
/* Missfile-specific DAT info */
bool usegame,
@@ -646,7 +646,7 @@ namespace SabreTools
ForcePacking = fp,
MergeRoms = dedup,
ExcludeOf = excludeOf,
OutputFormat = outputFormat,
DatFormat = datFormat,
UseGame = usegame,
Prefix = prefix,

View File

@@ -95,8 +95,8 @@ namespace SabreTools
updateDat = false, // SimpleSort
usegame = true;
DiffMode diffMode = 0x0;
OutputFormat outputFormat = 0x0;
StatOutputFormat statOutputFormat = StatOutputFormat.None;
DatFormat datFormat = 0x0;
StatDatFormat statDatFormat = StatDatFormat.None;
// User inputs
int gz = 2, // SimpleSort
@@ -222,7 +222,7 @@ namespace SabreTools
break;
case "-csv":
case "--csv":
statOutputFormat = StatOutputFormat.CSV;
statDatFormat = StatDatFormat.CSV;
break;
case "-dd":
case "--dedup":
@@ -266,7 +266,7 @@ namespace SabreTools
break;
case "-html":
case "--html":
statOutputFormat = StatOutputFormat.HTML;
statDatFormat = StatDatFormat.HTML;
break;
case "-ip":
case "--inplace":
@@ -290,59 +290,59 @@ namespace SabreTools
break;
case "-oa":
case "--output-all":
outputFormat |= OutputFormat.ALL;
datFormat |= DatFormat.ALL;
break;
case "-oc":
case "--output-cmp":
outputFormat |= OutputFormat.ClrMamePro;
datFormat |= DatFormat.ClrMamePro;
break;
case "-ocsv":
case "--output-csv":
outputFormat |= OutputFormat.CSV;
datFormat |= DatFormat.CSV;
break;
case "-od":
case "--output-dc":
outputFormat |= OutputFormat.DOSCenter;
datFormat |= DatFormat.DOSCenter;
break;
case "-om":
case "--output-miss":
outputFormat |= OutputFormat.MissFile;
datFormat |= DatFormat.MissFile;
break;
case "-omd5":
case "--output-md5":
outputFormat |= OutputFormat.RedumpMD5;
datFormat |= DatFormat.RedumpMD5;
break;
case "-ool":
case "--output-ol":
outputFormat |= OutputFormat.OfflineList;
datFormat |= DatFormat.OfflineList;
break;
case "-or":
case "--output-rc":
outputFormat |= OutputFormat.RomCenter;
datFormat |= DatFormat.RomCenter;
break;
case "-os":
case "--output-sd":
outputFormat |= OutputFormat.SabreDat;
datFormat |= DatFormat.SabreDat;
break;
case "-osfv":
case "--output-sfv":
outputFormat |= OutputFormat.RedumpSFV;
datFormat |= DatFormat.RedumpSFV;
break;
case "-osha1":
case "--output-sha1":
outputFormat |= OutputFormat.RedumpSHA1;
datFormat |= DatFormat.RedumpSHA1;
break;
case "-osl":
case "--output-sl":
outputFormat |= OutputFormat.SoftwareList;
datFormat |= DatFormat.SoftwareList;
break;
case "-otsv":
case "--output-tsv":
outputFormat |= OutputFormat.TSV;
datFormat |= DatFormat.TSV;
break;
case "-ox":
case "--output-xml":
outputFormat |= OutputFormat.Logiqx;
datFormat |= DatFormat.Logiqx;
break;
case "-q":
case "--quotes":
@@ -398,7 +398,7 @@ namespace SabreTools
break;
case "-tsv":
case "--tsv":
statOutputFormat = StatOutputFormat.TSV;
statDatFormat = StatDatFormat.TSV;
break;
case "-ud":
case "--update":
@@ -957,7 +957,7 @@ namespace SabreTools
author,
forcepack,
excludeOf,
outputFormat,
datFormat,
romba,
superdat,
noMD5,
@@ -1008,14 +1008,14 @@ namespace SabreTools
// Get statistics on input files
else if (stats)
{
InitStats(inputs, filename, single, showBaddumpColumn, showNodumpColumn, statOutputFormat);
InitStats(inputs, filename, single, showBaddumpColumn, showNodumpColumn, statDatFormat);
}
// Convert, update, merge, diff, and filter a DAT or folder of DATs
else if (update)
{
InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header,
superdat, forcemerge, forcend, forcepack, excludeOf, outputFormat, usegame, prefix,
superdat, forcemerge, forcend, forcepack, excludeOf, datFormat, usegame, prefix,
postfix, quotes, repext, addext, remext, datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName, gamename, romname,
romtype, sgt, slt, seq, crc, md5, sha1, status, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism);
}