mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, Utilities] Rename factory functions
This commit is contained in:
@@ -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<string> empties = new List<string>();
|
||||
|
||||
// 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<StatReportFormat, string> 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
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="input">Name of the file to create the archive from</param>
|
||||
/// <returns>Archive object representing the inputs</returns>
|
||||
public static BaseArchive CreateArchiveFromExistingInput(string input)
|
||||
public static BaseArchive GetArchive(string input)
|
||||
{
|
||||
BaseArchive archive = null;
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="archiveType">SharpCompress.Common.ArchiveType representing the archive to create</param>
|
||||
/// <returns>Archive object representing the inputs</returns>
|
||||
public static BaseArchive CreateArchiveFromArchiveType(ArchiveType archiveType)
|
||||
public static BaseArchive GetArchive(ArchiveType archiveType)
|
||||
{
|
||||
switch (archiveType)
|
||||
{
|
||||
@@ -507,7 +507,7 @@ namespace SabreTools.Library.Tools
|
||||
/// </summary>
|
||||
/// <param name="archiveType">SabreTools.Library.Data.SharpCompress.OutputFormat representing the archive to create</param>
|
||||
/// <returns>Archive object representing the inputs</returns>
|
||||
public static BaseArchive CreateArchiveFromOutputFormat(OutputFormat outputFormat)
|
||||
public static BaseArchive GetArchive(OutputFormat outputFormat)
|
||||
{
|
||||
switch (outputFormat)
|
||||
{
|
||||
@@ -538,13 +538,39 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of BaseReport to be used based on a format and user inputs
|
||||
/// </summary>
|
||||
/// <param name="statReportFormat">Format of the Statistics Report to be created</param>
|
||||
/// <param name="filename">Name of the file to write out to</param>
|
||||
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <returns>DatFile of the specific internal type that corresponds to the inputs</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a specific type of BaseReport to be used based on a format and user inputs
|
||||
/// </summary>
|
||||
/// <param name="statReportFormat">Format of the Statistics Report to be created</param>
|
||||
/// <param name="filename">Name of the file to write out to</param>
|
||||
/// <param name="baddumpCol">True if baddumps should be included in output, false otherwise</param>
|
||||
/// <param name="nodumpCol">True if nodumps should be included in output, false otherwise</param>
|
||||
/// <returns>BaseReport of the specific internal type that corresponds to the inputs</returns>
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user