diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 29015324..fb5207e8 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -3056,7 +3056,7 @@ namespace SabreTools.Library.DatFiles // Now parse the correct type of DAT try { - Utilities.CreateDatFileFromTypeAndBase(Utilities.GetDatFormat(filename), this)?.ParseFile(filename, sysid, srcid, keep, clean, remUnicode); + Utilities.GetDatFile(Utilities.GetDatFormat(filename), this)?.ParseFile(filename, sysid, srcid, keep, clean, remUnicode); } catch (Exception ex) { @@ -3488,7 +3488,7 @@ namespace SabreTools.Library.DatFiles if (!archivesAsFiles) { // Get the base archive first - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(newItem); + BaseArchive archive = Utilities.GetArchive(newItem); // Now get all extracted items from the archive if (archive != null) @@ -3527,7 +3527,7 @@ namespace SabreTools.Library.DatFiles List empties = new List(); // Get the base archive first - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(newItem); + BaseArchive archive = Utilities.GetArchive(newItem); // Now get all blank folders from the archive if (archive != null) @@ -4068,7 +4068,7 @@ namespace SabreTools.Library.DatFiles bool isTorrentGzip = tgz.IsTorrent(); // Get the base archive first - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(file); + BaseArchive archive = Utilities.GetArchive(file); // Now get all extracted items from the archive if (archive != null) @@ -4197,7 +4197,7 @@ namespace SabreTools.Library.DatFiles if (isZip != null) { string realName = null; - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(file); + BaseArchive archive = Utilities.GetArchive(file); if (archive != null) { (fileStream, realName) = archive.ExtractEntryStream(datItem.Name); @@ -4225,7 +4225,7 @@ namespace SabreTools.Library.DatFiles foreach (DatItem item in dupes) { // Get the output archive, if possible - BaseArchive outputArchive = Utilities.CreateArchiveFromOutputFormat(outputFormat); + BaseArchive outputArchive = Utilities.GetArchive(outputFormat); // Now rebuild to the output file outputArchive.Write(fileStream, outDir, (Rom)item, date: date, romba: romba); @@ -4279,7 +4279,7 @@ namespace SabreTools.Library.DatFiles if (isZip != null) { string realName = null; - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(file); + BaseArchive archive = Utilities.GetArchive(file); if (archive != null) { (fileStream, realName) = archive.ExtractEntryStream(datItem.Name); @@ -4312,7 +4312,7 @@ namespace SabreTools.Library.DatFiles Globals.Logger.User("No matches found for '{0}', rebuilding accordingly from inverse flag...", Path.GetFileName(datItem.Name)); // Get the output archive, if possible - BaseArchive outputArchive = Utilities.CreateArchiveFromOutputFormat(outputFormat); + BaseArchive outputArchive = Utilities.GetArchive(outputFormat); // Now rebuild to the output file if (outputArchive == null) @@ -4369,7 +4369,7 @@ namespace SabreTools.Library.DatFiles if (isZip != null) { string realName = null; - BaseArchive archive = Utilities.CreateArchiveFromExistingInput(file); + BaseArchive archive = Utilities.GetArchive(file); if (archive != null) { (fileStream, realName) = archive.ExtractEntryStream(datItem.Name); @@ -4429,7 +4429,7 @@ namespace SabreTools.Library.DatFiles bool eitherSuccess = false; // Get the output archive, if possible - BaseArchive outputArchive = Utilities.CreateArchiveFromOutputFormat(outputFormat); + BaseArchive outputArchive = Utilities.GetArchive(outputFormat); // Now rebuild to the output file eitherSuccess |= outputArchive.Write(transformStream, outDir, (Rom)item, date: date, romba: romba); @@ -5426,7 +5426,7 @@ namespace SabreTools.Library.DatFiles string outfile = outfiles[datFormat]; try { - Utilities.CreateDatFileFromTypeAndBase(datFormat, this)?.WriteToFile(outfile, ignoreblanks); + Utilities.GetDatFile(datFormat, this)?.WriteToFile(outfile, ignoreblanks); } catch (Exception ex) { @@ -5702,7 +5702,7 @@ namespace SabreTools.Library.DatFiles // Loop through and output based on the inputs foreach (KeyValuePair kvp in outputs) { - reports.Add(Utilities.CreateBaseReportFromType(kvp.Key, kvp.Value, baddumpCol, nodumpCol)); + reports.Add(Utilities.GetBaseReport(kvp.Key, kvp.Value, baddumpCol, nodumpCol)); } // Write the header, if any diff --git a/SabreTools.Library/Tools/Utilities.cs b/SabreTools.Library/Tools/Utilities.cs index fcc5e572..279f925f 100644 --- a/SabreTools.Library/Tools/Utilities.cs +++ b/SabreTools.Library/Tools/Utilities.cs @@ -441,7 +441,7 @@ namespace SabreTools.Library.Tools /// /// Name of the file to create the archive from /// Archive object representing the inputs - public static BaseArchive CreateArchiveFromExistingInput(string input) + public static BaseArchive GetArchive(string input) { BaseArchive archive = null; @@ -483,7 +483,7 @@ namespace SabreTools.Library.Tools /// /// SharpCompress.Common.ArchiveType representing the archive to create /// Archive object representing the inputs - public static BaseArchive CreateArchiveFromArchiveType(ArchiveType archiveType) + public static BaseArchive GetArchive(ArchiveType archiveType) { switch (archiveType) { @@ -507,7 +507,7 @@ namespace SabreTools.Library.Tools /// /// SabreTools.Library.Data.SharpCompress.OutputFormat representing the archive to create /// Archive object representing the inputs - public static BaseArchive CreateArchiveFromOutputFormat(OutputFormat outputFormat) + public static BaseArchive GetArchive(OutputFormat outputFormat) { switch (outputFormat) { @@ -538,13 +538,39 @@ namespace SabreTools.Library.Tools } } + + /// + /// Create a specific type of BaseReport to be used based on a format and user inputs + /// + /// Format of the Statistics Report to be created + /// Name of the file to write out to + /// True if baddumps should be included in output, false otherwise + /// True if nodumps should be included in output, false otherwise + /// BaseReport of the specific internal type that corresponds to the inputs + public static BaseReport GetBaseReport(StatReportFormat statReportFormat, string filename, bool baddumpCol, bool nodumpCol) + { + switch (statReportFormat) + { + case StatReportFormat.Textfile: + return new Textfile(null, filename, baddumpCol, nodumpCol); + case StatReportFormat.CSV: + return new Reports.SeparatedValue(null, filename, ',', baddumpCol, nodumpCol); + case StatReportFormat.HTML: + return new Html(null, filename, baddumpCol, nodumpCol); + case StatReportFormat.TSV: + return new Reports.SeparatedValue(null, filename, '\t', baddumpCol, nodumpCol); + } + + return 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 /// DatFile of the specific internal type that corresponds to the inputs - public static DatFile CreateDatFileFromTypeAndBase(DatFormat datFormat, DatFile baseDat) + public static DatFile GetDatFile(DatFormat datFormat, DatFile baseDat) { switch (datFormat) { @@ -589,31 +615,6 @@ namespace SabreTools.Library.Tools return null; } - /// - /// Create a specific type of BaseReport to be used based on a format and user inputs - /// - /// Format of the Statistics Report to be created - /// Name of the file to write out to - /// True if baddumps should be included in output, false otherwise - /// True if nodumps should be included in output, false otherwise - /// BaseReport of the specific internal type that corresponds to the inputs - public static BaseReport CreateBaseReportFromType(StatReportFormat statReportFormat, string filename, bool baddumpCol, bool nodumpCol) - { - switch (statReportFormat) - { - case StatReportFormat.Textfile: - return new Textfile(null, filename, baddumpCol, nodumpCol); - case StatReportFormat.CSV: - return new Reports.SeparatedValue(null, filename, ',', baddumpCol, nodumpCol); - case StatReportFormat.HTML: - return new Html(null, filename, baddumpCol, nodumpCol); - case StatReportFormat.TSV: - return new Reports.SeparatedValue(null, filename, '\t', baddumpCol, nodumpCol); - } - - return null; - } - #endregion #region File Information