diff --git a/SabreTools.Core/Tools/Converters.cs b/SabreTools.Core/Tools/Converters.cs
index e69e85c8..14a9ca55 100644
--- a/SabreTools.Core/Tools/Converters.cs
+++ b/SabreTools.Core/Tools/Converters.cs
@@ -7,37 +7,6 @@ namespace SabreTools.Core.Tools
{
#region Enum to Enum
- ///
- /// Get the field associated with each hash type
- ///
- public static Field AsField(this Hash hash)
- {
- switch (hash)
- {
- case Hash.CRC:
- return Field.DatItem_CRC;
- case Hash.MD5:
- return Field.DatItem_MD5;
-#if NET_FRAMEWORK
- case Hash.RIPEMD160:
- return Field.DatItem_RIPEMD160;
-#endif
- case Hash.SHA1:
- return Field.DatItem_SHA1;
- case Hash.SHA256:
- return Field.DatItem_SHA256;
- case Hash.SHA384:
- return Field.DatItem_SHA384;
- case Hash.SHA512:
- return Field.DatItem_SHA512;
- case Hash.SpamSum:
- return Field.DatItem_SpamSum;
-
- default:
- return Field.NULL;
- }
- }
-
///
/// Get the fields associated with each hash type
///
@@ -164,91 +133,6 @@ namespace SabreTools.Core.Tools
#endif
}
- ///
- /// Get DatFormat value from input string
- ///
- /// String to get value from
- /// DatFormat value corresponding to the string
- public static DatFormat AsDatFormat(this string input)
- {
- switch (input?.Trim().ToLowerInvariant())
- {
- case "all":
- return DatFormat.ALL;
- case "am":
- case "attractmode":
- return DatFormat.AttractMode;
- case "cmp":
- case "clrmamepro":
- return DatFormat.ClrMamePro;
- case "csv":
- return DatFormat.CSV;
- case "dc":
- case "doscenter":
- return DatFormat.DOSCenter;
- case "everdrive":
- case "smdb":
- return DatFormat.EverdriveSMDB;
- case "json":
- case "sj":
- case "sabrejson":
- return DatFormat.SabreJSON;
- case "lr":
- case "listrom":
- return DatFormat.Listrom;
- case "lx":
- case "listxml":
- return DatFormat.Listxml;
- case "md5":
- return DatFormat.RedumpMD5;
- case "miss":
- case "missfile":
- return DatFormat.MissFile;
- case "msx":
- case "openmsx":
- return DatFormat.OpenMSX;
- case "ol":
- case "offlinelist":
- return DatFormat.OfflineList;
- case "rc":
- case "romcenter":
- return DatFormat.RomCenter;
-#if NET_FRAMEWORK
- case "ripemd160":
- return DatFormat.RedumpRIPEMD160;
-#endif
- case "sd":
- case "sabredat":
- case "sx":
- case "sabrexml":
- return DatFormat.SabreXML;
- case "sfv":
- return DatFormat.RedumpSFV;
- case "sha1":
- return DatFormat.RedumpSHA1;
- case "sha256":
- return DatFormat.RedumpSHA256;
- case "sha384":
- return DatFormat.RedumpSHA384;
- case "sha512":
- return DatFormat.RedumpSHA512;
- case "sl":
- case "softwarelist":
- return DatFormat.SoftwareList;
- case "spamsum":
- return DatFormat.RedumpSpamSum;
- case "ssv":
- return DatFormat.SSV;
- case "tsv":
- return DatFormat.TSV;
- case "xml":
- case "logiqx":
- return DatFormat.Logiqx;
- default:
- return 0x0;
- }
- }
-
///
/// Get DeviceType value from input string
///
@@ -2243,45 +2127,6 @@ namespace SabreTools.Core.Tools
#endif
}
- ///
- /// Get StatReportFormat value from input string
- ///
- /// String to get value from
- /// StatReportFormat value corresponding to the string
- public static StatReportFormat AsStatReportFormat(this string input)
- {
-#if NET_FRAMEWORK
- switch (input?.Trim().ToLowerInvariant())
- {
- case "all":
- return StatReportFormat.All;
- case "csv":
- return StatReportFormat.CSV;
- case "html":
- return StatReportFormat.HTML;
- case "ssv":
- return StatReportFormat.SSV;
- case "text":
- return StatReportFormat.Textfile;
- case "tsv":
- return StatReportFormat.TSV;
- default:
- return 0x0;
- }
-#else
- return input?.Trim().ToLowerInvariant() switch
- {
- "all" => StatReportFormat.All,
- "csv" => StatReportFormat.CSV,
- "html" => StatReportFormat.HTML,
- "ssv" => StatReportFormat.SSV,
- "text" => StatReportFormat.Textfile,
- "tsv" => StatReportFormat.TSV,
- _ => 0x0,
- };
-#endif
- }
-
///
/// Get Supported value from input string
///
@@ -2561,7 +2406,6 @@ namespace SabreTools.Core.Tools
#endif
}
-
///
/// Get string value from input DisplayType
///
@@ -3072,57 +2916,6 @@ namespace SabreTools.Core.Tools
#endif
}
- ///
- /// Get string value from input OutputFormat
- ///
- /// OutputFormat to get value from
- /// String value corresponding to the OutputFormat
- public static string FromOutputFormat(this OutputFormat itemType)
- {
-#if NET_FRAMEWORK
- switch (itemType)
- {
- case OutputFormat.Folder:
- case OutputFormat.ParentFolder:
- return "directory";
- case OutputFormat.TapeArchive:
- return "TAR";
- case OutputFormat.Torrent7Zip:
- return "Torrent7Z";
- case OutputFormat.TorrentGzip:
- case OutputFormat.TorrentGzipRomba:
- return "TorrentGZ";
- case OutputFormat.TorrentLRZip:
- return "TorrentLRZ";
- case OutputFormat.TorrentRar:
- return "TorrentRAR";
- case OutputFormat.TorrentXZ:
- case OutputFormat.TorrentXZRomba:
- return "TorrentXZ";
- case OutputFormat.TorrentZip:
- return "TorrentZip";
- default:
- return null;
- }
-#else
- return itemType switch
- {
- OutputFormat.Folder => "directory",
- OutputFormat.ParentFolder => "directory",
- OutputFormat.TapeArchive => "TAR",
- OutputFormat.Torrent7Zip => "Torrent7Z",
- OutputFormat.TorrentGzip => "TorrentGZ",
- OutputFormat.TorrentGzipRomba => "TorrentGZ",
- OutputFormat.TorrentLRZip => "TorrentLRZ",
- OutputFormat.TorrentRar => "TorrentRAR",
- OutputFormat.TorrentXZ => "TorrentXZ",
- OutputFormat.TorrentXZRomba => "TorrentXZ",
- OutputFormat.TorrentZip => "TorrentZip",
- _ => null,
- };
-#endif
- }
-
///
/// Get string value from input PackingFlag
///
@@ -3253,45 +3046,6 @@ namespace SabreTools.Core.Tools
#endif
}
- ///
- /// Get string value from input StatReportFormat
- ///
- /// StatReportFormat to get value from
- /// String value corresponding to the StatReportFormat
- public static string FromStatReportFormat(this StatReportFormat input)
- {
-#if NET_FRAMEWORK
- switch (input)
- {
- case StatReportFormat.All:
- return "all";
- case StatReportFormat.CSV:
- return "csv";
- case StatReportFormat.HTML:
- return "html";
- case StatReportFormat.SSV:
- return "ssv";
- case StatReportFormat.Textfile:
- return "text";
- case StatReportFormat.TSV:
- return "tsv";
- default:
- return null;
- }
-#else
- return input switch
- {
- StatReportFormat.All => "all",
- StatReportFormat.CSV => "csv",
- StatReportFormat.HTML => "html",
- StatReportFormat.SSV => "ssv",
- StatReportFormat.Textfile => "text",
- StatReportFormat.TSV => "tsv",
- _ => null,
- };
-#endif
- }
-
///
/// Get string value from input Supported
///
diff --git a/SabreTools.DatFiles/DatFile.Rebuilding.cs b/SabreTools.DatFiles/DatFile.Rebuilding.cs
index 3c6e1301..22d8a92b 100644
--- a/SabreTools.DatFiles/DatFile.Rebuilding.cs
+++ b/SabreTools.DatFiles/DatFile.Rebuilding.cs
@@ -59,7 +59,7 @@ namespace SabreTools.DatFiles
#region Rebuild from depots in order
- string format = outputFormat.FromOutputFormat() ?? string.Empty;
+ string format = FromOutputFormat(outputFormat) ?? string.Empty;
InternalStopwatch watch = new InternalStopwatch($"Rebuilding all files to {format}");
// Now loop through and get only directories from the input paths
@@ -199,7 +199,7 @@ namespace SabreTools.DatFiles
#region Rebuild from sources in order
- string format = outputFormat.FromOutputFormat() ?? string.Empty;
+ string format = FromOutputFormat(outputFormat) ?? string.Empty;
InternalStopwatch watch = new InternalStopwatch($"Rebuilding all files to {format}");
// Now loop through all of the files in all of the inputs
@@ -633,7 +633,7 @@ namespace SabreTools.DatFiles
///
/// Get the default OutputFormat associated with each PackingFlag
///
- public OutputFormat GetOutputFormat(PackingFlag packing)
+ private OutputFormat GetOutputFormat(PackingFlag packing)
{
#if NET_FRAMEWORK
switch (packing)
@@ -682,5 +682,56 @@ namespace SabreTools.DatFiles
return outputArchive;
}
+
+ ///
+ /// Get string value from input OutputFormat
+ ///
+ /// OutputFormat to get value from
+ /// String value corresponding to the OutputFormat
+ private string FromOutputFormat(OutputFormat itemType)
+ {
+#if NET_FRAMEWORK
+ switch (itemType)
+ {
+ case OutputFormat.Folder:
+ case OutputFormat.ParentFolder:
+ return "directory";
+ case OutputFormat.TapeArchive:
+ return "TAR";
+ case OutputFormat.Torrent7Zip:
+ return "Torrent7Z";
+ case OutputFormat.TorrentGzip:
+ case OutputFormat.TorrentGzipRomba:
+ return "TorrentGZ";
+ case OutputFormat.TorrentLRZip:
+ return "TorrentLRZ";
+ case OutputFormat.TorrentRar:
+ return "TorrentRAR";
+ case OutputFormat.TorrentXZ:
+ case OutputFormat.TorrentXZRomba:
+ return "TorrentXZ";
+ case OutputFormat.TorrentZip:
+ return "TorrentZip";
+ default:
+ return null;
+ }
+#else
+ return itemType switch
+ {
+ OutputFormat.Folder => "directory",
+ OutputFormat.ParentFolder => "directory",
+ OutputFormat.TapeArchive => "TAR",
+ OutputFormat.Torrent7Zip => "Torrent7Z",
+ OutputFormat.TorrentGzip => "TorrentGZ",
+ OutputFormat.TorrentGzipRomba => "TorrentGZ",
+ OutputFormat.TorrentLRZip => "TorrentLRZ",
+ OutputFormat.TorrentRar => "TorrentRAR",
+ OutputFormat.TorrentXZ => "TorrentXZ",
+ OutputFormat.TorrentXZRomba => "TorrentXZ",
+ OutputFormat.TorrentZip => "TorrentZip",
+ _ => null,
+ };
+#endif
+ }
}
}
\ No newline at end of file
diff --git a/SabreTools/Features/BaseFeature.cs b/SabreTools/Features/BaseFeature.cs
index 8309f459..e02f4bf0 100644
--- a/SabreTools/Features/BaseFeature.cs
+++ b/SabreTools/Features/BaseFeature.cs
@@ -2603,7 +2603,7 @@ Some special strings that can be used:
foreach (string rt in GetList(features, ReportTypeListValue))
{
- statDatFormat |= rt.AsStatReportFormat();
+ statDatFormat |= GetStatReportFormat(rt);
}
return statDatFormat;
@@ -2812,7 +2812,7 @@ Some special strings that can be used:
bool deprecated = GetBoolean(features, DeprecatedValue);
foreach (string ot in GetList(features, OutputTypeListValue))
{
- DatFormat dftemp = ot.AsDatFormat();
+ DatFormat dftemp = GetDatFormat(ot);
if (dftemp == DatFormat.Logiqx && deprecated)
datHeader.DatFormat |= DatFormat.LogiqxDeprecated;
else
@@ -3103,10 +3103,134 @@ CREATE TABLE IF NOT EXISTS data (
dbc.Dispose();
}
+ ///
+ /// Get DatFormat value from input string
+ ///
+ /// String to get value from
+ /// DatFormat value corresponding to the string
+ protected static DatFormat GetDatFormat(string input)
+ {
+ switch (input?.Trim().ToLowerInvariant())
+ {
+ case "all":
+ return DatFormat.ALL;
+ case "am":
+ case "attractmode":
+ return DatFormat.AttractMode;
+ case "cmp":
+ case "clrmamepro":
+ return DatFormat.ClrMamePro;
+ case "csv":
+ return DatFormat.CSV;
+ case "dc":
+ case "doscenter":
+ return DatFormat.DOSCenter;
+ case "everdrive":
+ case "smdb":
+ return DatFormat.EverdriveSMDB;
+ case "json":
+ case "sj":
+ case "sabrejson":
+ return DatFormat.SabreJSON;
+ case "lr":
+ case "listrom":
+ return DatFormat.Listrom;
+ case "lx":
+ case "listxml":
+ return DatFormat.Listxml;
+ case "md5":
+ return DatFormat.RedumpMD5;
+ case "miss":
+ case "missfile":
+ return DatFormat.MissFile;
+ case "msx":
+ case "openmsx":
+ return DatFormat.OpenMSX;
+ case "ol":
+ case "offlinelist":
+ return DatFormat.OfflineList;
+ case "rc":
+ case "romcenter":
+ return DatFormat.RomCenter;
+#if NET_FRAMEWORK
+ case "ripemd160":
+ return DatFormat.RedumpRIPEMD160;
+#endif
+ case "sd":
+ case "sabredat":
+ case "sx":
+ case "sabrexml":
+ return DatFormat.SabreXML;
+ case "sfv":
+ return DatFormat.RedumpSFV;
+ case "sha1":
+ return DatFormat.RedumpSHA1;
+ case "sha256":
+ return DatFormat.RedumpSHA256;
+ case "sha384":
+ return DatFormat.RedumpSHA384;
+ case "sha512":
+ return DatFormat.RedumpSHA512;
+ case "sl":
+ case "softwarelist":
+ return DatFormat.SoftwareList;
+ case "spamsum":
+ return DatFormat.RedumpSpamSum;
+ case "ssv":
+ return DatFormat.SSV;
+ case "tsv":
+ return DatFormat.TSV;
+ case "xml":
+ case "logiqx":
+ return DatFormat.Logiqx;
+ default:
+ return 0x0;
+ }
+ }
+
#endregion
#region Private Helpers
+ ///
+ /// Get StatReportFormat value from input string
+ ///
+ /// String to get value from
+ /// StatReportFormat value corresponding to the string
+ private static StatReportFormat GetStatReportFormat(string input)
+ {
+#if NET_FRAMEWORK
+ switch (input?.Trim().ToLowerInvariant())
+ {
+ case "all":
+ return StatReportFormat.All;
+ case "csv":
+ return StatReportFormat.CSV;
+ case "html":
+ return StatReportFormat.HTML;
+ case "ssv":
+ return StatReportFormat.SSV;
+ case "text":
+ return StatReportFormat.Textfile;
+ case "tsv":
+ return StatReportFormat.TSV;
+ default:
+ return 0x0;
+ }
+#else
+ return input?.Trim().ToLowerInvariant() switch
+ {
+ "all" => StatReportFormat.All,
+ "csv" => StatReportFormat.CSV,
+ "html" => StatReportFormat.HTML,
+ "ssv" => StatReportFormat.SSV,
+ "text" => StatReportFormat.Textfile,
+ "tsv" => StatReportFormat.TSV,
+ _ => 0x0,
+ };
+#endif
+ }
+
///
/// Get the multiplier to be used with the size given
///
diff --git a/SabreTools/Features/Batch.cs b/SabreTools/Features/Batch.cs
index 7168dfec..2a65798b 100644
--- a/SabreTools/Features/Batch.cs
+++ b/SabreTools/Features/Batch.cs
@@ -358,7 +358,7 @@ Reset the internal state: reset();";
datFile.Header.DatFormat = 0x00;
foreach (string format in command.Arguments)
{
- datFile.Header.DatFormat |= format.AsDatFormat();
+ datFile.Header.DatFormat |= GetDatFormat(format);
}
// If we had an invalid input, log and continue