diff --git a/SabreTools.DatFiles/DatHeader.cs b/SabreTools.DatFiles/DatHeader.cs
index deaa3a12..3a840c7a 100644
--- a/SabreTools.DatFiles/DatHeader.cs
+++ b/SabreTools.DatFiles/DatHeader.cs
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.IO;
using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
@@ -435,285 +433,5 @@ namespace SabreTools.DatFiles
public bool PassesFilter(FilterRunner filterRunner) => filterRunner.Run(_internal);
#endregion
-
- #region Writing
-
- ///
- /// Map of all formats to extensions, including "backup" extensions
- ///
- private static readonly Dictionary ExtensionMappings = new()
- {
- // .csv
- { DatFormat.CSV, new string[] { ".csv" } },
-
- // .dat
- { DatFormat.ClrMamePro, new string[] { ".dat" } },
- { DatFormat.RomCenter, new string[] { ".dat", ".rc.dat" } },
- { DatFormat.DOSCenter, new string[] { ".dat", ".dc.dat" } },
-
- // .json
- { DatFormat.SabreJSON, new string[] { ".json" } },
-
- // .md2
- { DatFormat.RedumpMD2, new string[] { ".md2" } },
-
- // .md4
- { DatFormat.RedumpMD4, new string[] { ".md4" } },
-
- // .md5
- { DatFormat.RedumpMD5, new string[] { ".md5" } },
-
- // .sfv
- { DatFormat.RedumpSFV, new string[] { ".sfv" } },
-
- // .sha1
- { DatFormat.RedumpSHA1, new string[] { ".sha1" } },
-
- // .sha256
- { DatFormat.RedumpSHA256, new string[] { ".sha256" } },
-
- // .sha384
- { DatFormat.RedumpSHA384, new string[] { ".sha384" } },
-
- // .sha512
- { DatFormat.RedumpSHA512, new string[] { ".sha512" } },
-
- // .spamsum
- { DatFormat.RedumpSpamSum, new string[] { ".spamsum" } },
-
- // .ssv
- { DatFormat.SSV, new string[] { ".ssv" } },
-
- // .tsv
- { DatFormat.TSV, new string[] { ".tsv" } },
-
- // .txt
- { DatFormat.AttractMode, new string[] { ".txt" } },
- { DatFormat.Listrom, new string[] { ".txt", ".lr.txt" } },
- { DatFormat.MissFile, new string[] { ".txt", ".miss.txt" } },
- { DatFormat.EverdriveSMDB, new string[] { ".txt", ".smdb.txt" } },
-
- // .xml
- { DatFormat.Logiqx, new string[] { ".xml" } },
- { DatFormat.LogiqxDeprecated, new string[] { ".xml", ".xml" } }, // Intentional duplicate
- { DatFormat.SabreXML, new string[] { ".xml", ".sd.xml" } },
- { DatFormat.SoftwareList, new string[] { ".xml", ".sl.xml" } },
- { DatFormat.Listxml, new string[] { ".xml", ".mame.xml" } },
- { DatFormat.OfflineList, new string[] { ".xml", ".ol.xml" } },
- { DatFormat.OpenMSX, new string[] { ".xml", ".msx.xml" } },
- { DatFormat.ArchiveDotOrg, new string[] { ".xml", ".ado.xml" } },
- };
-
- ///
- /// Generate a proper outfile name based on a DAT and output directory
- ///
- /// DatHeader value to pull information from
- /// Output directory
- /// True if we ignore existing files (default), false otherwise
- /// Dictionary of output formats mapped to file names
- public static Dictionary CreateOutFileNames(DatHeader datHeader, string outDir, bool overwrite = true)
- {
- // Create the output dictionary
- Dictionary outfileNames = [];
-
- // Get the filename to use
- string? filename = string.IsNullOrEmpty(datHeader.GetStringFieldValue(DatHeader.FileNameKey))
- ? datHeader.GetStringFieldValue(Models.Metadata.Header.DescriptionKey)
- : datHeader.GetStringFieldValue(DatHeader.FileNameKey);
-
- // Strip off the extension if it's a holdover from the DAT
- if (Utilities.HasValidDatExtension(filename))
- filename = Path.GetFileNameWithoutExtension(filename);
-
- // Double check the outDir for the end delim
- if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
- outDir += Path.DirectorySeparatorChar;
-
- // Get the current format types
- DatFormat datFormat = datHeader.GetFieldValue(DatHeader.DatFormatKey);
- List usedFormats = SplitFormats(datFormat);
-
- // Get the extensions from the output type
- List usedExtensions = [];
- foreach (var map in ExtensionMappings)
- {
- // Split the pair
- DatFormat format = map.Key;
- string[] extensions = map.Value;
-
- // Ignore unused formats
- if (!usedFormats.Contains(format))
- continue;
-
- // Get the correct extension, assuming a backup exists
- string extension = extensions[0];
- if (usedExtensions.Contains(extension))
- extension = extensions[1];
-
- // Create the filename and set the extension as used
- outfileNames.Add(format, CreateOutFileNamesHelper(filename, outDir, extension, overwrite));
- usedExtensions.Add(extension);
- }
-
- return outfileNames;
- }
-
- ///
- /// Help generating the outfile name
- ///
- /// Base filename to use
- /// Output directory
- /// Extension to use for the file
- /// True if we ignore existing files, false otherwise
- /// String containing the new filename
- private static string CreateOutFileNamesHelper(string? filename, string outDir, string extension, bool overwrite)
- {
- string outfile = $"{outDir}{filename}{extension}";
- outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
-
- if (!overwrite)
- {
- int i = 1;
- while (File.Exists(outfile))
- {
- outfile = $"{outDir}{filename}_{i}{extension}";
- outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
- i++;
- }
- }
-
- return outfile;
- }
-
- ///
- /// Split a format flag into multiple distinct values
- ///
- /// Combined DatFormat value to split
- /// List representing the individual flag values set
- /// TODO: Consider making DatFormat a non-flag enum so this doesn't need to happen
- private static List SplitFormats(DatFormat datFormat)
- {
- List usedFormats = [];
-
-#if NET20 || NET35
- if ((datFormat & DatFormat.ArchiveDotOrg) != 0)
- usedFormats.Add(DatFormat.ArchiveDotOrg);
- if ((datFormat & DatFormat.AttractMode) != 0)
- usedFormats.Add(DatFormat.AttractMode);
- if ((datFormat & DatFormat.ClrMamePro) != 0)
- usedFormats.Add(DatFormat.ClrMamePro);
- if ((datFormat & DatFormat.CSV) != 0)
- usedFormats.Add(DatFormat.CSV);
- if ((datFormat & DatFormat.DOSCenter) != 0)
- usedFormats.Add(DatFormat.DOSCenter);
- if ((datFormat & DatFormat.EverdriveSMDB) != 0)
- usedFormats.Add(DatFormat.EverdriveSMDB);
- if ((datFormat & DatFormat.Listrom) != 0)
- usedFormats.Add(DatFormat.Listrom);
- if ((datFormat & DatFormat.Listxml) != 0)
- usedFormats.Add(DatFormat.Listxml);
- if ((datFormat & DatFormat.Logiqx) != 0)
- usedFormats.Add(DatFormat.Logiqx);
- if ((datFormat & DatFormat.LogiqxDeprecated) != 0)
- usedFormats.Add(DatFormat.LogiqxDeprecated);
- if ((datFormat & DatFormat.MissFile) != 0)
- usedFormats.Add(DatFormat.MissFile);
- if ((datFormat & DatFormat.OfflineList) != 0)
- usedFormats.Add(DatFormat.OfflineList);
- if ((datFormat & DatFormat.OpenMSX) != 0)
- usedFormats.Add(DatFormat.OpenMSX);
- if ((datFormat & DatFormat.RedumpMD2) != 0)
- usedFormats.Add(DatFormat.RedumpMD2);
- if ((datFormat & DatFormat.RedumpMD4) != 0)
- usedFormats.Add(DatFormat.RedumpMD4);
- if ((datFormat & DatFormat.RedumpMD5) != 0)
- usedFormats.Add(DatFormat.RedumpMD5);
- if ((datFormat & DatFormat.RedumpSFV) != 0)
- usedFormats.Add(DatFormat.RedumpSFV);
- if ((datFormat & DatFormat.RedumpSHA1) != 0)
- usedFormats.Add(DatFormat.RedumpSHA1);
- if ((datFormat & DatFormat.RedumpSHA256) != 0)
- usedFormats.Add(DatFormat.RedumpSHA256);
- if ((datFormat & DatFormat.RedumpSHA384) != 0)
- usedFormats.Add(DatFormat.RedumpSHA384);
- if ((datFormat & DatFormat.RedumpSHA512) != 0)
- usedFormats.Add(DatFormat.RedumpSHA512);
- if ((datFormat & DatFormat.RedumpSpamSum) != 0)
- usedFormats.Add(DatFormat.RedumpSpamSum);
- if ((datFormat & DatFormat.RomCenter) != 0)
- usedFormats.Add(DatFormat.RomCenter);
- if ((datFormat & DatFormat.SabreJSON) != 0)
- usedFormats.Add(DatFormat.SabreJSON);
- if ((datFormat & DatFormat.SabreXML) != 0)
- usedFormats.Add(DatFormat.SabreXML);
- if ((datFormat & DatFormat.SoftwareList) != 0)
- usedFormats.Add(DatFormat.SoftwareList);
- if ((datFormat & DatFormat.SSV) != 0)
- usedFormats.Add(DatFormat.SSV);
- if ((datFormat & DatFormat.TSV) != 0)
- usedFormats.Add(DatFormat.TSV);
-#else
- if (datFormat.HasFlag(DatFormat.ArchiveDotOrg))
- usedFormats.Add(DatFormat.ArchiveDotOrg);
- if (datFormat.HasFlag(DatFormat.AttractMode))
- usedFormats.Add(DatFormat.AttractMode);
- if (datFormat.HasFlag(DatFormat.ClrMamePro))
- usedFormats.Add(DatFormat.ClrMamePro);
- if (datFormat.HasFlag(DatFormat.CSV))
- usedFormats.Add(DatFormat.CSV);
- if (datFormat.HasFlag(DatFormat.DOSCenter))
- usedFormats.Add(DatFormat.DOSCenter);
- if (datFormat.HasFlag(DatFormat.EverdriveSMDB))
- usedFormats.Add(DatFormat.EverdriveSMDB);
- if (datFormat.HasFlag(DatFormat.Listrom))
- usedFormats.Add(DatFormat.Listrom);
- if (datFormat.HasFlag(DatFormat.Listxml))
- usedFormats.Add(DatFormat.Listxml);
- if (datFormat.HasFlag(DatFormat.Logiqx))
- usedFormats.Add(DatFormat.Logiqx);
- if (datFormat.HasFlag(DatFormat.LogiqxDeprecated))
- usedFormats.Add(DatFormat.LogiqxDeprecated);
- if (datFormat.HasFlag(DatFormat.MissFile))
- usedFormats.Add(DatFormat.MissFile);
- if (datFormat.HasFlag(DatFormat.OfflineList))
- usedFormats.Add(DatFormat.OfflineList);
- if (datFormat.HasFlag(DatFormat.OpenMSX))
- usedFormats.Add(DatFormat.OpenMSX);
- if (datFormat.HasFlag(DatFormat.RedumpMD2))
- usedFormats.Add(DatFormat.RedumpMD2);
- if (datFormat.HasFlag(DatFormat.RedumpMD4))
- usedFormats.Add(DatFormat.RedumpMD4);
- if (datFormat.HasFlag(DatFormat.RedumpMD5))
- usedFormats.Add(DatFormat.RedumpMD5);
- if (datFormat.HasFlag(DatFormat.RedumpSFV))
- usedFormats.Add(DatFormat.RedumpSFV);
- if (datFormat.HasFlag(DatFormat.RedumpSHA1))
- usedFormats.Add(DatFormat.RedumpSHA1);
- if (datFormat.HasFlag(DatFormat.RedumpSHA256))
- usedFormats.Add(DatFormat.RedumpSHA256);
- if (datFormat.HasFlag(DatFormat.RedumpSHA384))
- usedFormats.Add(DatFormat.RedumpSHA384);
- if (datFormat.HasFlag(DatFormat.RedumpSHA512))
- usedFormats.Add(DatFormat.RedumpSHA512);
- if (datFormat.HasFlag(DatFormat.RedumpSpamSum))
- usedFormats.Add(DatFormat.RedumpSpamSum);
- if (datFormat.HasFlag(DatFormat.RomCenter))
- usedFormats.Add(DatFormat.RomCenter);
- if (datFormat.HasFlag(DatFormat.SabreJSON))
- usedFormats.Add(DatFormat.SabreJSON);
- if (datFormat.HasFlag(DatFormat.SabreXML))
- usedFormats.Add(DatFormat.SabreXML);
- if (datFormat.HasFlag(DatFormat.SoftwareList))
- usedFormats.Add(DatFormat.SoftwareList);
- if (datFormat.HasFlag(DatFormat.SSV))
- usedFormats.Add(DatFormat.SSV);
- if (datFormat.HasFlag(DatFormat.TSV))
- usedFormats.Add(DatFormat.TSV);
-#endif
-
- return usedFormats;
- }
-
- #endregion
}
}
diff --git a/SabreTools.DatTools/Writer.cs b/SabreTools.DatTools/Writer.cs
index ce7a284f..a53b8166 100644
--- a/SabreTools.DatTools/Writer.cs
+++ b/SabreTools.DatTools/Writer.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.IO;
#if NET40_OR_GREATER || NETCOREAPP
using System.Threading.Tasks;
#endif
+using SabreTools.Core.Tools;
using SabreTools.DatFiles;
using SabreTools.DatItems;
using SabreTools.IO.Extensions;
@@ -153,7 +155,7 @@ namespace SabreTools.DatTools
_staticLogger.User($"A total of {datFile.DatStatistics.TotalCount - datFile.DatStatistics.RemovedCount} items will be written out to '{datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)}'");
// Get the outfile names
- Dictionary outfiles = DatHeader.CreateOutFileNames(datFile.Header, outDir!, overwrite);
+ Dictionary outfiles = CreateOutFileNames(datFile.Header, outDir!, overwrite);
try
{
@@ -221,6 +223,87 @@ namespace SabreTools.DatTools
consoleOutput!.WriteToFile(null, true, true);
}
+ ///
+ /// Generate a proper outfile name based on a DAT and output directory
+ ///
+ /// DatHeader value to pull information from
+ /// Output directory
+ /// True if we ignore existing files (default), false otherwise
+ /// Dictionary of output formats mapped to file names
+ internal static Dictionary CreateOutFileNames(DatHeader datHeader, string outDir, bool overwrite = true)
+ {
+ // Create the output dictionary
+ Dictionary outfileNames = [];
+
+ // Get the filename to use
+ string? filename = string.IsNullOrEmpty(datHeader.GetStringFieldValue(DatHeader.FileNameKey))
+ ? datHeader.GetStringFieldValue(Models.Metadata.Header.DescriptionKey)
+ : datHeader.GetStringFieldValue(DatHeader.FileNameKey);
+
+ // Strip off the extension if it's a holdover from the DAT
+ if (Utilities.HasValidDatExtension(filename))
+ filename = Path.GetFileNameWithoutExtension(filename);
+
+ // Double check the outDir for the end delim
+ if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
+ outDir += Path.DirectorySeparatorChar;
+
+ // Get the current format types
+ DatFormat datFormat = datHeader.GetFieldValue(DatHeader.DatFormatKey);
+ List usedFormats = SplitFormats(datFormat);
+
+ // Get the extensions from the output type
+ List usedExtensions = [];
+ foreach (var map in ExtensionMappings)
+ {
+ // Split the pair
+ DatFormat format = map.Key;
+ string[] extensions = map.Value;
+
+ // Ignore unused formats
+ if (!usedFormats.Contains(format))
+ continue;
+
+ // Get the correct extension, assuming a backup exists
+ string extension = extensions[0];
+ if (usedExtensions.Contains(extension))
+ extension = extensions[1];
+
+ // Create the filename and set the extension as used
+ outfileNames.Add(format, CreateOutFileNamesHelper(filename, outDir, extension, overwrite));
+ usedExtensions.Add(extension);
+ }
+
+ return outfileNames;
+ }
+
+ ///
+ /// Help generating the outfile name
+ ///
+ /// Base filename to use
+ /// Output directory
+ /// Extension to use for the file
+ /// True if we ignore existing files, false otherwise
+ /// String containing the new filename
+ private static string CreateOutFileNamesHelper(string? filename, string outDir, string extension, bool overwrite)
+ {
+ string outfile = $"{outDir}{filename}{extension}";
+ outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
+
+ if (!overwrite)
+ {
+ int i = 1;
+ while (File.Exists(outfile))
+ {
+ outfile = $"{outDir}{filename}_{i}{extension}";
+ outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
+ i++;
+ }
+ }
+
+ return outfile;
+ }
+
///
/// Ensure that FileName, Name, and Description are filled with some value
///
@@ -300,5 +383,134 @@ namespace SabreTools.DatTools
return true;
}
+
+ ///
+ /// Split a format flag into multiple distinct values
+ ///
+ /// Combined DatFormat value to split
+ /// List representing the individual flag values set
+ /// TODO: Consider making DatFormat a non-flag enum so this doesn't need to happen
+ private static List SplitFormats(DatFormat datFormat)
+ {
+ List usedFormats = [];
+
+#if NET20 || NET35
+ if ((datFormat & DatFormat.ArchiveDotOrg) != 0)
+ usedFormats.Add(DatFormat.ArchiveDotOrg);
+ if ((datFormat & DatFormat.AttractMode) != 0)
+ usedFormats.Add(DatFormat.AttractMode);
+ if ((datFormat & DatFormat.ClrMamePro) != 0)
+ usedFormats.Add(DatFormat.ClrMamePro);
+ if ((datFormat & DatFormat.CSV) != 0)
+ usedFormats.Add(DatFormat.CSV);
+ if ((datFormat & DatFormat.DOSCenter) != 0)
+ usedFormats.Add(DatFormat.DOSCenter);
+ if ((datFormat & DatFormat.EverdriveSMDB) != 0)
+ usedFormats.Add(DatFormat.EverdriveSMDB);
+ if ((datFormat & DatFormat.Listrom) != 0)
+ usedFormats.Add(DatFormat.Listrom);
+ if ((datFormat & DatFormat.Listxml) != 0)
+ usedFormats.Add(DatFormat.Listxml);
+ if ((datFormat & DatFormat.Logiqx) != 0)
+ usedFormats.Add(DatFormat.Logiqx);
+ if ((datFormat & DatFormat.LogiqxDeprecated) != 0)
+ usedFormats.Add(DatFormat.LogiqxDeprecated);
+ if ((datFormat & DatFormat.MissFile) != 0)
+ usedFormats.Add(DatFormat.MissFile);
+ if ((datFormat & DatFormat.OfflineList) != 0)
+ usedFormats.Add(DatFormat.OfflineList);
+ if ((datFormat & DatFormat.OpenMSX) != 0)
+ usedFormats.Add(DatFormat.OpenMSX);
+ if ((datFormat & DatFormat.RedumpMD2) != 0)
+ usedFormats.Add(DatFormat.RedumpMD2);
+ if ((datFormat & DatFormat.RedumpMD4) != 0)
+ usedFormats.Add(DatFormat.RedumpMD4);
+ if ((datFormat & DatFormat.RedumpMD5) != 0)
+ usedFormats.Add(DatFormat.RedumpMD5);
+ if ((datFormat & DatFormat.RedumpSFV) != 0)
+ usedFormats.Add(DatFormat.RedumpSFV);
+ if ((datFormat & DatFormat.RedumpSHA1) != 0)
+ usedFormats.Add(DatFormat.RedumpSHA1);
+ if ((datFormat & DatFormat.RedumpSHA256) != 0)
+ usedFormats.Add(DatFormat.RedumpSHA256);
+ if ((datFormat & DatFormat.RedumpSHA384) != 0)
+ usedFormats.Add(DatFormat.RedumpSHA384);
+ if ((datFormat & DatFormat.RedumpSHA512) != 0)
+ usedFormats.Add(DatFormat.RedumpSHA512);
+ if ((datFormat & DatFormat.RedumpSpamSum) != 0)
+ usedFormats.Add(DatFormat.RedumpSpamSum);
+ if ((datFormat & DatFormat.RomCenter) != 0)
+ usedFormats.Add(DatFormat.RomCenter);
+ if ((datFormat & DatFormat.SabreJSON) != 0)
+ usedFormats.Add(DatFormat.SabreJSON);
+ if ((datFormat & DatFormat.SabreXML) != 0)
+ usedFormats.Add(DatFormat.SabreXML);
+ if ((datFormat & DatFormat.SoftwareList) != 0)
+ usedFormats.Add(DatFormat.SoftwareList);
+ if ((datFormat & DatFormat.SSV) != 0)
+ usedFormats.Add(DatFormat.SSV);
+ if ((datFormat & DatFormat.TSV) != 0)
+ usedFormats.Add(DatFormat.TSV);
+#else
+ if (datFormat.HasFlag(DatFormat.ArchiveDotOrg))
+ usedFormats.Add(DatFormat.ArchiveDotOrg);
+ if (datFormat.HasFlag(DatFormat.AttractMode))
+ usedFormats.Add(DatFormat.AttractMode);
+ if (datFormat.HasFlag(DatFormat.ClrMamePro))
+ usedFormats.Add(DatFormat.ClrMamePro);
+ if (datFormat.HasFlag(DatFormat.CSV))
+ usedFormats.Add(DatFormat.CSV);
+ if (datFormat.HasFlag(DatFormat.DOSCenter))
+ usedFormats.Add(DatFormat.DOSCenter);
+ if (datFormat.HasFlag(DatFormat.EverdriveSMDB))
+ usedFormats.Add(DatFormat.EverdriveSMDB);
+ if (datFormat.HasFlag(DatFormat.Listrom))
+ usedFormats.Add(DatFormat.Listrom);
+ if (datFormat.HasFlag(DatFormat.Listxml))
+ usedFormats.Add(DatFormat.Listxml);
+ if (datFormat.HasFlag(DatFormat.Logiqx))
+ usedFormats.Add(DatFormat.Logiqx);
+ if (datFormat.HasFlag(DatFormat.LogiqxDeprecated))
+ usedFormats.Add(DatFormat.LogiqxDeprecated);
+ if (datFormat.HasFlag(DatFormat.MissFile))
+ usedFormats.Add(DatFormat.MissFile);
+ if (datFormat.HasFlag(DatFormat.OfflineList))
+ usedFormats.Add(DatFormat.OfflineList);
+ if (datFormat.HasFlag(DatFormat.OpenMSX))
+ usedFormats.Add(DatFormat.OpenMSX);
+ if (datFormat.HasFlag(DatFormat.RedumpMD2))
+ usedFormats.Add(DatFormat.RedumpMD2);
+ if (datFormat.HasFlag(DatFormat.RedumpMD4))
+ usedFormats.Add(DatFormat.RedumpMD4);
+ if (datFormat.HasFlag(DatFormat.RedumpMD5))
+ usedFormats.Add(DatFormat.RedumpMD5);
+ if (datFormat.HasFlag(DatFormat.RedumpSFV))
+ usedFormats.Add(DatFormat.RedumpSFV);
+ if (datFormat.HasFlag(DatFormat.RedumpSHA1))
+ usedFormats.Add(DatFormat.RedumpSHA1);
+ if (datFormat.HasFlag(DatFormat.RedumpSHA256))
+ usedFormats.Add(DatFormat.RedumpSHA256);
+ if (datFormat.HasFlag(DatFormat.RedumpSHA384))
+ usedFormats.Add(DatFormat.RedumpSHA384);
+ if (datFormat.HasFlag(DatFormat.RedumpSHA512))
+ usedFormats.Add(DatFormat.RedumpSHA512);
+ if (datFormat.HasFlag(DatFormat.RedumpSpamSum))
+ usedFormats.Add(DatFormat.RedumpSpamSum);
+ if (datFormat.HasFlag(DatFormat.RomCenter))
+ usedFormats.Add(DatFormat.RomCenter);
+ if (datFormat.HasFlag(DatFormat.SabreJSON))
+ usedFormats.Add(DatFormat.SabreJSON);
+ if (datFormat.HasFlag(DatFormat.SabreXML))
+ usedFormats.Add(DatFormat.SabreXML);
+ if (datFormat.HasFlag(DatFormat.SoftwareList))
+ usedFormats.Add(DatFormat.SoftwareList);
+ if (datFormat.HasFlag(DatFormat.SSV))
+ usedFormats.Add(DatFormat.SSV);
+ if (datFormat.HasFlag(DatFormat.TSV))
+ usedFormats.Add(DatFormat.TSV);
+#endif
+
+ return usedFormats;
+ }
}
}
\ No newline at end of file
diff --git a/SabreTools.Test/DatFiles/DatHeaderTests.cs b/SabreTools.Test/DatFiles/DatHeaderTests.cs
index 87dc3d4b..a2aba24a 100644
--- a/SabreTools.Test/DatFiles/DatHeaderTests.cs
+++ b/SabreTools.Test/DatFiles/DatHeaderTests.cs
@@ -1,8 +1,10 @@
using SabreTools.DatFiles;
+using SabreTools.DatTools;
using Xunit;
namespace SabreTools.Test.DatFiles
{
+ // TODO: Migrate tests to WriterTests when available
public class DatHeaderTests
{
[Theory]
@@ -20,7 +22,7 @@ namespace SabreTools.Test.DatFiles
// Invoke the method
string outDir = "C:\\Test";
- var actual = DatHeader.CreateOutFileNames(datHeader, outDir, overwrite: true);
+ var actual = Writer.CreateOutFileNames(datHeader, outDir, overwrite: true);
// Check the result
string expected = $"{outDir}{System.IO.Path.DirectorySeparatorChar}test.{extension}";
@@ -38,7 +40,7 @@ namespace SabreTools.Test.DatFiles
// Invoke the method
string outDir = "C:\\Test";
- var actual = DatHeader.CreateOutFileNames(datHeader, outDir, overwrite: true);
+ var actual = Writer.CreateOutFileNames(datHeader, outDir, overwrite: true);
// Check the result
Assert.Equal(28, actual.Count);