mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, DatFile, Utilities] Add "output-type" flag (not hooked up)
This commit is contained in:
@@ -3222,7 +3222,7 @@ namespace SabreTools.Library.DatFiles
|
||||
FileName = (String.IsNullOrWhiteSpace(FileName) ? (keepext ? Path.GetFileName(filename) : Path.GetFileNameWithoutExtension(filename)) : FileName);
|
||||
|
||||
// If the output type isn't set already, get the internal output type
|
||||
DatFormat = (DatFormat == 0 ? Utilities.GetDatFormat(filename) : DatFormat);
|
||||
DatFormat = (DatFormat == 0 ? Utilities.GetDatFormatFromFile(filename) : DatFormat);
|
||||
|
||||
// Now parse the correct type of DAT
|
||||
try
|
||||
|
||||
@@ -595,7 +595,7 @@ namespace SabreTools.Library.Tools
|
||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatFile GetDatFile(string input, DatFile baseDat)
|
||||
{
|
||||
DatFormat datFormat = GetDatFormat(input);
|
||||
DatFormat datFormat = GetDatFormatFromFile(input);
|
||||
return GetDatFile(datFormat, baseDat);
|
||||
}
|
||||
|
||||
@@ -681,6 +681,69 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get DatFormat value from input string
|
||||
/// </summary>
|
||||
/// <param name="input">String to get value from</param>
|
||||
/// <returns>DatFormat value corresponding to the string</returns>
|
||||
public static DatFormat GetDatFormat(string input)
|
||||
{
|
||||
switch (input?.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 "lr":
|
||||
case "listrom":
|
||||
return DatFormat.Listrom;
|
||||
case "lx":
|
||||
case "listxml":
|
||||
return DatFormat.Listxml;
|
||||
case "miss":
|
||||
case "missfile":
|
||||
return DatFormat.MissFile;
|
||||
case "md5":
|
||||
return DatFormat.RedumpMD5;
|
||||
case "ol":
|
||||
case "offlinelist":
|
||||
return DatFormat.OfflineList;
|
||||
case "rc":
|
||||
case "romcenter":
|
||||
return DatFormat.RomCenter;
|
||||
case "sd":
|
||||
case "sabredat":
|
||||
return DatFormat.SabreDat;
|
||||
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 "xml":
|
||||
case "logiqx":
|
||||
return DatFormat.Logiqx;
|
||||
default:
|
||||
return DatFormat.Logiqx; // TODO: Placeholder until DatFormat.None
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get ForceMerging value from input string
|
||||
/// </summary>
|
||||
@@ -1048,7 +1111,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <returns>The DatFormat corresponding to the DAT</returns>
|
||||
public static DatFormat GetDatFormat(string filename)
|
||||
public static DatFormat GetDatFormatFromFile(string filename)
|
||||
{
|
||||
// Limit the output formats based on extension
|
||||
if (!HasValidDatExtension(filename))
|
||||
|
||||
@@ -1616,6 +1616,26 @@ namespace SabreTools
|
||||
});
|
||||
}
|
||||
}
|
||||
private static Feature outputTypeListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
new List<string>() { "-ot", "--output-type" },
|
||||
"Output DATs to a given type or types",
|
||||
FeatureType.List,
|
||||
new List<string>()
|
||||
{
|
||||
" Supported values are:",
|
||||
" all, am/attractmode, cmp/clrmamepro, csv,",
|
||||
" dc/doscenter, lr/listrom, lx/listxml,",
|
||||
" miss/missfile, md5, ol/offlinelist,",
|
||||
" rc/romcenter, sd/sabredat, sfv, sha1,",
|
||||
" sha256, sha384, sha512, sl/softwarelist",
|
||||
" xml/logiqx",
|
||||
});
|
||||
}
|
||||
}
|
||||
private static Feature sha1ListInput
|
||||
{
|
||||
get
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace SabreTools
|
||||
if ((datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0)
|
||||
{
|
||||
datHeader.DatFormat |= DatFormat.Logiqx;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "quick":
|
||||
quickScan = true;
|
||||
@@ -652,6 +652,17 @@ namespace SabreTools
|
||||
filter.NotItemStatuses |= Utilities.GetItemStatus(nstat);
|
||||
}
|
||||
break;
|
||||
case "output-type":
|
||||
foreach (string ot in (List<string>)feat.Value.GetValue())
|
||||
{
|
||||
DatFormat dftemp = Utilities.GetDatFormat(ot);
|
||||
if (dftemp != DatFormat.Logiqx
|
||||
|| (dftemp == DatFormat.Logiqx && (datHeader.DatFormat & DatFormat.LogiqxDepreciated) == 0))
|
||||
{
|
||||
datHeader.DatFormat |= dftemp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "sha1":
|
||||
filter.SHA1s.AddRange((List<string>)feat.Value.GetValue());
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user