diff --git a/SabreTools.DatFiles/DatFileTool.cs b/SabreTools.DatFiles/DatFileTool.cs index 558422f6..323938a0 100644 --- a/SabreTools.DatFiles/DatFileTool.cs +++ b/SabreTools.DatFiles/DatFileTool.cs @@ -36,7 +36,7 @@ namespace SabreTools.DatFiles /// /// A default Logiqx DatFile public static DatFile CreateDatFile() - => CreateDatFile(DatFormat.Logiqx, baseDat: null, quotes: true); + => CreateDatFile(DatFormat.Logiqx, baseDat: null); /// /// Create a specific type of DatFile to be used based on a format @@ -44,22 +44,21 @@ namespace SabreTools.DatFiles /// Format of the DAT to be created /// DatFile of the specific internal type public static DatFile CreateDatFile(DatFormat datFormat) - => CreateDatFile(datFormat, baseDat: null, quotes: true); + => CreateDatFile(datFormat, baseDat: null); /// /// Create a specific type of DatFile to be used based on a format and a base DAT /// /// Format of the DAT to be created /// DatFile containing the information to use in specific operations - /// For relevant types, assume the usage of quotes /// DatFile of the specific internal type that corresponds to the inputs - 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), diff --git a/SabreTools.DatFiles/Formats/ClrMamePro.cs b/SabreTools.DatFiles/Formats/ClrMamePro.cs index 2b6d207b..012abb0a 100644 --- a/SabreTools.DatFiles/Formats/ClrMamePro.cs +++ b/SabreTools.DatFiles/Formats/ClrMamePro.cs @@ -31,21 +31,14 @@ namespace SabreTools.DatFiles.Formats ItemType.Sound, ]; - /// - /// Get whether to assume quote usage on read and write or not - /// - private readonly bool _quotes; - #endregion /// /// Constructor designed for casting a base DatFile /// /// Parent DatFile to copy from - /// Enable quotes on read and write, false otherwise - public ClrMamePro(DatFile? datFile, bool quotes) : base(datFile) + public ClrMamePro(DatFile? datFile) : base(datFile) { - _quotes = quotes; } /// @@ -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; diff --git a/SabreTools.DatFiles/Parser.cs b/SabreTools.DatFiles/Parser.cs index 4b753382..7fa8308c 100644 --- a/SabreTools.DatFiles/Parser.cs +++ b/SabreTools.DatFiles/Parser.cs @@ -48,7 +48,6 @@ namespace SabreTools.DatFiles /// Index ID for the DAT /// True if full pathnames are to be kept, false otherwise (default) /// True if original extension should be kept, false otherwise (default) - /// True if quotes are assumed in supported types (default), false otherwise /// True to only add item statistics while parsing, false otherwise /// True if the error that is thrown should be thrown back to the caller, false otherwise 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); } /// @@ -73,7 +71,6 @@ namespace SabreTools.DatFiles /// Index ID for the DAT /// True if full pathnames are to be kept, false otherwise (default) /// True if original extension should be kept, false otherwise (default) - /// True if quotes are assumed in supported types (default), false otherwise /// True to only add item statistics while parsing, false otherwise /// True if the error that is thrown should be thrown back to the caller, false otherwise 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) diff --git a/SabreTools.DatTools/Writer.cs b/SabreTools.DatTools/Writer.cs index b9b4290f..0a73b63d 100644 --- a/SabreTools.DatTools/Writer.cs +++ b/SabreTools.DatTools/Writer.cs @@ -30,18 +30,29 @@ namespace SabreTools.DatTools /// /// Current DatFile object to write from /// Set the output directory (current directory on null) - /// True if files should be overwritten (default), false if they should be renamed instead - /// True if blank roms should be skipped on output, false otherwise (default) - /// True if quotes are assumed in supported types (default), false otherwise + /// True if the DAT was written correctly, false otherwise + public static bool Write(DatFile datFile, string? outDir) + => Write(datFile, outDir, overwrite: true, throwOnError: false); + + /// + /// Create and open an output file for writing direct from a dictionary + /// + /// Current DatFile object to write from + /// Set the output directory (current directory on null) + /// True if files should be overwritten, false if they should be renamed instead + /// True if the DAT was written correctly, false otherwise + public static bool Write(DatFile datFile, string? outDir, bool overwrite) + => Write(datFile, outDir, overwrite, throwOnError: false); + + /// + /// Create and open an output file for writing direct from a dictionary + /// + /// Current DatFile object to write from + /// Set the output directory (current directory on null) + /// True if files should be overwritten, false if they should be renamed instead /// True if the error that is thrown should be thrown back to the caller, false otherwise /// True if the DAT was written correctly, false otherwise - 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) {