mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Remove external quotes parameter for CMP
This commit is contained in:
@@ -36,7 +36,7 @@ namespace SabreTools.DatFiles
|
||||
/// </summary>
|
||||
/// <returns>A default Logiqx DatFile</returns>
|
||||
public static DatFile CreateDatFile()
|
||||
=> CreateDatFile(DatFormat.Logiqx, baseDat: null, quotes: true);
|
||||
=> CreateDatFile(DatFormat.Logiqx, baseDat: null);
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of DatFile to be used based on a format
|
||||
@@ -44,22 +44,21 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="datFormat">Format of the DAT to be created</param>
|
||||
/// <returns>DatFile of the specific internal type</returns>
|
||||
public static DatFile CreateDatFile(DatFormat datFormat)
|
||||
=> CreateDatFile(datFormat, baseDat: null, quotes: true);
|
||||
=> CreateDatFile(datFormat, baseDat: null);
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of DatFile to be used based on a format and a base DAT
|
||||
/// </summary>
|
||||
/// <param name="datFormat">Format of the DAT to be created</param>
|
||||
/// <param name="baseDat">DatFile containing the information to use in specific operations</param>
|
||||
/// <param name="quotes">For relevant types, assume the usage of quotes</param>
|
||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||
public static DatFile CreateDatFile(DatFormat datFormat, DatFile? baseDat, bool quotes)
|
||||
public static DatFile CreateDatFile(DatFormat datFormat, DatFile? baseDat)
|
||||
{
|
||||
return datFormat switch
|
||||
{
|
||||
DatFormat.ArchiveDotOrg => new ArchiveDotOrg(baseDat),
|
||||
DatFormat.AttractMode => new AttractMode(baseDat),
|
||||
DatFormat.ClrMamePro => new ClrMamePro(baseDat, quotes),
|
||||
DatFormat.ClrMamePro => new ClrMamePro(baseDat),
|
||||
DatFormat.CSV => new CommaSeparatedValue(baseDat),
|
||||
DatFormat.DOSCenter => new DosCenter(baseDat),
|
||||
DatFormat.EverdriveSMDB => new EverdriveSMDB(baseDat),
|
||||
|
||||
@@ -31,21 +31,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
ItemType.Sound,
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
/// Get whether to assume quote usage on read and write or not
|
||||
/// </summary>
|
||||
private readonly bool _quotes;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Constructor designed for casting a base DatFile
|
||||
/// </summary>
|
||||
/// <param name="datFile">Parent DatFile to copy from</param>
|
||||
/// <param name="quotes">Enable quotes on read and write, false otherwise</param>
|
||||
public ClrMamePro(DatFile? datFile, bool quotes) : base(datFile)
|
||||
public ClrMamePro(DatFile? datFile) : base(datFile)
|
||||
{
|
||||
_quotes = quotes;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -54,7 +47,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
try
|
||||
{
|
||||
// Deserialize the input file
|
||||
var metadataFile = Serialization.Deserializers.ClrMamePro.DeserializeFile(filename, _quotes);
|
||||
var metadataFile = Serialization.Deserializers.ClrMamePro.DeserializeFile(filename, quotes: true);
|
||||
var metadata = new Serialization.CrossModel.ClrMamePro().Serialize(metadataFile);
|
||||
|
||||
// Convert to the internal format
|
||||
@@ -176,7 +169,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
// Serialize the input file
|
||||
var metadata = ConvertToMetadata(ignoreblanks);
|
||||
var metadataFile = new Serialization.CrossModel.ClrMamePro().Deserialize(metadata);
|
||||
if (!Serialization.Serializers.ClrMamePro.SerializeFile(metadataFile, outfile, _quotes))
|
||||
if (!Serialization.Serializers.ClrMamePro.SerializeFile(metadataFile, outfile, quotes: true))
|
||||
{
|
||||
_logger.Warning($"File '{outfile}' could not be written! See the log for more details.");
|
||||
return false;
|
||||
|
||||
@@ -48,7 +48,6 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
||||
/// <param name="quotes">True if quotes are assumed in supported types (default), false otherwise</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
public static void ParseInto(
|
||||
@@ -57,12 +56,11 @@ namespace SabreTools.DatFiles
|
||||
int indexId = 0,
|
||||
bool keep = false,
|
||||
bool keepext = false,
|
||||
bool quotes = true,
|
||||
bool statsOnly = false,
|
||||
bool throwOnError = false)
|
||||
{
|
||||
ParentablePath path = new(filename.Trim('"'));
|
||||
ParseInto(datFile, path, indexId, keep, keepext, quotes, statsOnly, throwOnError);
|
||||
var path = new ParentablePath(filename.Trim('"'));
|
||||
ParseInto(datFile, path, indexId, keep, keepext, statsOnly, throwOnError);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -73,7 +71,6 @@ namespace SabreTools.DatFiles
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// <param name="keepext">True if original extension should be kept, false otherwise (default)</param>
|
||||
/// <param name="quotes">True if quotes are assumed in supported types (default), false otherwise</param>
|
||||
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
public static void ParseInto(
|
||||
@@ -82,9 +79,8 @@ namespace SabreTools.DatFiles
|
||||
int indexId = 0,
|
||||
bool keep = false,
|
||||
bool keepext = false,
|
||||
bool quotes = true,
|
||||
bool statsOnly = false,
|
||||
bool throwOnError = true)
|
||||
bool throwOnError = false)
|
||||
{
|
||||
// Get the current path from the filename
|
||||
string currentPath = input.CurrentPath;
|
||||
@@ -112,7 +108,7 @@ namespace SabreTools.DatFiles
|
||||
// Now parse the correct type of DAT
|
||||
try
|
||||
{
|
||||
DatFile parsingDatFile = DatFileTool.CreateDatFile(currentPathFormat, datFile, quotes);
|
||||
DatFile parsingDatFile = DatFileTool.CreateDatFile(currentPathFormat, datFile);
|
||||
parsingDatFile.ParseFile(currentPath, indexId, keep, statsOnly: statsOnly, throwOnError: throwOnError);
|
||||
}
|
||||
catch (Exception ex) when (!throwOnError)
|
||||
|
||||
@@ -30,18 +30,29 @@ namespace SabreTools.DatTools
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to write from</param>
|
||||
/// <param name="outDir">Set the output directory (current directory on null)</param>
|
||||
/// <param name="overwrite">True if files should be overwritten (default), false if they should be renamed instead</param>
|
||||
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
||||
/// <param name="quotes">True if quotes are assumed in supported types (default), false otherwise</param>
|
||||
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
||||
public static bool Write(DatFile datFile, string? outDir)
|
||||
=> Write(datFile, outDir, overwrite: true, throwOnError: false);
|
||||
|
||||
/// <summary>
|
||||
/// Create and open an output file for writing direct from a dictionary
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to write from</param>
|
||||
/// <param name="outDir">Set the output directory (current directory on null)</param>
|
||||
/// <param name="overwrite">True if files should be overwritten, false if they should be renamed instead</param>
|
||||
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
||||
public static bool Write(DatFile datFile, string? outDir, bool overwrite)
|
||||
=> Write(datFile, outDir, overwrite, throwOnError: false);
|
||||
|
||||
/// <summary>
|
||||
/// Create and open an output file for writing direct from a dictionary
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to write from</param>
|
||||
/// <param name="outDir">Set the output directory (current directory on null)</param>
|
||||
/// <param name="overwrite">True if files should be overwritten, false if they should be renamed instead</param>
|
||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
||||
public static bool Write(
|
||||
DatFile datFile,
|
||||
string? outDir,
|
||||
bool overwrite = true,
|
||||
bool ignoreblanks = false,
|
||||
bool quotes = true,
|
||||
bool throwOnError = false)
|
||||
public static bool Write(DatFile datFile, string? outDir, bool overwrite, bool throwOnError)
|
||||
{
|
||||
// If we have nothing writable, abort
|
||||
if (!HasWritable(datFile))
|
||||
@@ -90,8 +101,8 @@ namespace SabreTools.DatTools
|
||||
string outfile = outfiles[datFormat];
|
||||
try
|
||||
{
|
||||
DatFile writingDatFile = DatFileTool.CreateDatFile(datFormat, datFile, quotes);
|
||||
writingDatFile.WriteToFile(outfile, ignoreblanks, throwOnError);
|
||||
DatFile writingDatFile = DatFileTool.CreateDatFile(datFormat, datFile);
|
||||
writingDatFile.WriteToFile(outfile, ignoreblanks: true, throwOnError);
|
||||
}
|
||||
catch (Exception ex) when (!throwOnError)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user