2020-12-10 11:28:11 -08:00
using System ;
using System.Collections.Generic ;
2025-01-29 13:25:36 -05:00
using System.IO ;
2024-03-05 03:04:47 -05:00
#if NET40_OR_GREATER | | NETCOREAPP
2020-12-10 11:28:11 -08:00
using System.Threading.Tasks ;
2024-03-05 03:04:47 -05:00
#endif
2025-01-29 13:25:36 -05:00
using SabreTools.Core.Tools ;
2020-12-10 23:24:09 -08:00
using SabreTools.DatFiles ;
2020-12-14 15:43:01 -08:00
using SabreTools.DatItems ;
2024-04-24 13:45:38 -04:00
using SabreTools.IO.Extensions ;
2024-10-24 00:36:44 -04:00
using SabreTools.IO.Logging ;
2020-12-11 10:10:56 -08:00
using SabreTools.Reports ;
2020-12-10 11:28:11 -08:00
2020-12-10 23:24:09 -08:00
namespace SabreTools.DatTools
2020-12-10 11:28:11 -08:00
{
2020-12-21 11:38:56 -08:00
/// <summary>
/// Helper methods for writing from DatFiles
/// </summary>
2020-12-10 14:03:07 -08:00
public class Writer
2020-12-10 11:28:11 -08:00
{
2025-01-29 13:16:20 -05:00
#region Private Constants
/// <summary>
/// Map of all formats to extensions, including "backup" extensions
/// </summary>
private static readonly Dictionary < DatFormat , string [ ] > 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" } } ,
} ;
#endregion
2020-12-10 14:03:07 -08:00
#region Logging
/// <summary>
/// Logging object
/// </summary>
2025-01-08 16:59:44 -05:00
private static readonly Logger _staticLogger = new ( ) ;
2020-12-10 14:03:07 -08:00
#endregion
2020-12-10 11:28:11 -08:00
/// <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>
2025-01-12 20:49:22 -05:00
/// <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>
2020-12-10 11:28:11 -08:00
/// <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>
2025-01-12 20:49:22 -05:00
public static bool Write ( DatFile datFile , string? outDir , bool overwrite , bool throwOnError )
2020-12-10 11:28:11 -08:00
{
// If we have nothing writable, abort
if ( ! HasWritable ( datFile ) )
{
2025-01-08 16:59:44 -05:00
_staticLogger . User ( "There were no items to write out!" ) ;
2020-12-10 11:28:11 -08:00
return false ;
}
// Ensure the output directory is set and created
2024-03-12 16:47:21 -04:00
outDir = outDir . Ensure ( create : true ) ;
2020-12-10 11:28:11 -08:00
2023-04-19 16:39:58 -04:00
InternalStopwatch watch = new ( $"Writing out internal dat to '{outDir}'" ) ;
2021-02-02 14:09:49 -08:00
2020-12-10 11:28:11 -08:00
// If the DAT has no output format, default to XML
2024-03-10 21:54:07 -04:00
if ( datFile . Header . GetFieldValue < DatFormat > ( DatHeader . DatFormatKey ) = = 0 )
2020-12-10 11:28:11 -08:00
{
2025-01-08 16:59:44 -05:00
_staticLogger . Verbose ( "No DAT format defined, defaulting to XML" ) ;
2024-03-10 21:54:07 -04:00
datFile . Header . SetFieldValue < DatFormat > ( DatHeader . DatFormatKey , DatFormat . Logiqx ) ;
2020-12-10 11:28:11 -08:00
}
// Make sure that the three essential fields are filled in
2020-12-10 11:58:46 -08:00
EnsureHeaderFields ( datFile ) ;
2020-12-10 11:28:11 -08:00
// Bucket roms by game name, if not already
2025-01-14 20:21:54 -05:00
datFile . BucketBy ( ItemKey . Machine ) ;
2020-12-10 11:28:11 -08:00
// Output the number of items we're going to be writing
2025-01-12 23:15:30 -05:00
_staticLogger . User ( $"A total of {datFile.DatStatistics.TotalCount - datFile.DatStatistics.RemovedCount} items will be written out to '{datFile.Header.GetStringFieldValue(DatHeader.FileNameKey)}'" ) ;
2020-12-10 11:28:11 -08:00
// Get the outfile names
2025-01-29 13:25:36 -05:00
Dictionary < DatFormat , string > outfiles = CreateOutFileNames ( datFile . Header , outDir ! , overwrite ) ;
2020-12-10 11:28:11 -08:00
try
{
// Write out all required formats
2024-02-28 22:54:56 -05:00
#if NET452_OR_GREATER | | NETCOREAPP
2024-10-24 05:58:03 -04:00
Parallel . ForEach ( outfiles . Keys , Core . Globals . ParallelOptions , datFormat = >
2024-02-28 22:54:56 -05:00
#elif NET40_OR_GREATER
Parallel . ForEach ( outfiles . Keys , datFormat = >
#else
foreach ( var datFormat in outfiles . Keys )
#endif
2020-12-10 11:28:11 -08:00
{
string outfile = outfiles [ datFormat ] ;
try
{
2025-02-12 15:43:46 -05:00
DatFile writingDatFile = Parser . CreateDatFile ( datFormat , datFile ) ;
2025-01-12 20:49:22 -05:00
writingDatFile . WriteToFile ( outfile , ignoreblanks : true , throwOnError ) ;
2020-12-10 11:28:11 -08:00
}
2021-01-12 15:54:14 -08:00
catch ( Exception ex ) when ( ! throwOnError )
2020-12-10 11:28:11 -08:00
{
2025-01-08 16:59:44 -05:00
_staticLogger . Error ( ex , $"Datfile '{outfile}' could not be written out" ) ;
2020-12-10 11:28:11 -08:00
}
2024-02-28 21:59:13 -05:00
#if NET40_OR_GREATER | | NETCOREAPP
2020-12-10 11:28:11 -08:00
} ) ;
2024-02-28 21:59:13 -05:00
#else
}
#endif
2020-12-10 11:28:11 -08:00
}
2021-01-12 15:54:14 -08:00
catch ( Exception ex ) when ( ! throwOnError )
2020-12-10 11:28:11 -08:00
{
2025-01-08 16:59:44 -05:00
_staticLogger . Error ( ex ) ;
2020-12-10 11:28:11 -08:00
return false ;
}
2021-02-02 14:09:49 -08:00
finally
{
watch . Stop ( ) ;
}
2020-12-10 11:28:11 -08:00
return true ;
}
2020-12-10 15:52:31 -08:00
/// <summary>
/// Write the stats out to console for the current DatFile
/// </summary>
/// <param name="datFile">Current DatFile object to write from</param>
public static void WriteStatsToConsole ( DatFile datFile )
{
2025-01-12 23:15:30 -05:00
long diskCount = datFile . DatStatistics . GetItemCount ( ItemType . Disk ) ;
long mediaCount = datFile . DatStatistics . GetItemCount ( ItemType . Media ) ;
long romCount = datFile . DatStatistics . GetItemCount ( ItemType . Rom ) ;
2024-03-04 22:52:03 -05:00
if ( diskCount + mediaCount + romCount = = 0 )
2025-01-14 15:46:42 -05:00
datFile . RecalculateStats ( ) ;
2020-12-10 15:52:31 -08:00
2025-01-14 20:21:54 -05:00
datFile . BucketBy ( ItemKey . Machine , norename : true ) ;
2024-03-19 23:15:58 -04:00
2025-01-12 23:15:30 -05:00
datFile . DatStatistics . DisplayName = datFile . Header . GetStringFieldValue ( DatHeader . FileNameKey ) ;
2025-01-14 15:59:47 -05:00
datFile . DatStatistics . MachineCount = datFile . Items . SortedKeys . Length ;
2024-03-19 23:15:58 -04:00
2024-12-06 23:16:09 -05:00
List < DatStatistics > statsList =
[
2025-01-12 23:15:30 -05:00
datFile . DatStatistics ,
2024-12-06 23:16:09 -05:00
] ;
2025-02-19 13:24:12 -05:00
var consoleOutput = Parser . Create ( StatReportFormat . None , statsList ) ;
2024-02-28 19:19:50 -05:00
consoleOutput ! . WriteToFile ( null , true , true ) ;
2020-12-10 15:52:31 -08:00
}
2025-01-29 13:25:36 -05:00
/// <summary>
/// Generate a proper outfile name based on a DAT and output directory
/// </summary>
/// <param name="datHeader">DatHeader value to pull information from</param>
/// <param name="outDir">Output directory</param>
/// <param name="overwrite">True if we ignore existing files (default), false otherwise</param>
/// <returns>Dictionary of output formats mapped to file names</returns>
internal static Dictionary < DatFormat , string > CreateOutFileNames ( DatHeader datHeader , string outDir , bool overwrite = true )
{
// Create the output dictionary
Dictionary < DatFormat , string > 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 < DatFormat > ( DatHeader . DatFormatKey ) ;
List < DatFormat > usedFormats = SplitFormats ( datFormat ) ;
// Get the extensions from the output type
List < string > 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 ;
}
/// <summary>
/// Help generating the outfile name
/// </summary>
/// <param name="filename">Base filename to use</param>
/// <param name="outDir">Output directory</param>
/// <param name="extension">Extension to use for the file</param>
/// <param name="overwrite">True if we ignore existing files, false otherwise</param>
/// <returns>String containing the new filename</returns>
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 ;
}
2020-12-10 11:28:11 -08:00
/// <summary>
/// Ensure that FileName, Name, and Description are filled with some value
/// </summary>
/// <param name="datFile">Current DatFile object to write from</param>
2020-12-10 11:58:46 -08:00
private static void EnsureHeaderFields ( DatFile datFile )
2020-12-10 11:28:11 -08:00
{
// Empty FileName
2024-03-11 15:46:44 -04:00
if ( string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( DatHeader . FileNameKey ) ) )
2020-12-10 11:28:11 -08:00
{
2024-03-11 15:46:44 -04:00
if ( string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-07-17 15:46:42 -04:00
datFile . Header . SetFieldValue < string? > ( DatHeader . FileNameKey , "Default" ) ;
2024-03-10 04:10:37 -04:00
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . NameKey , "Default" ) ;
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . DescriptionKey , "Default" ) ;
}
2020-12-10 11:28:11 -08:00
2024-03-11 15:46:44 -04:00
else if ( string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-07-17 15:46:42 -04:00
datFile . Header . SetFieldValue < string? > ( DatHeader . FileNameKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) ;
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . NameKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
2024-03-11 15:46:44 -04:00
else if ( ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( DatHeader . FileNameKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) ;
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . DescriptionKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
2024-03-11 15:46:44 -04:00
else if ( ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( DatHeader . FileNameKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
}
// Filled FileName
else
{
2024-03-11 15:46:44 -04:00
if ( string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . NameKey , datFile . Header . GetStringFieldValue ( DatHeader . FileNameKey ) ) ;
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . DescriptionKey , datFile . Header . GetStringFieldValue ( DatHeader . FileNameKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
2024-03-11 15:46:44 -04:00
else if ( string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . NameKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
2024-03-11 15:46:44 -04:00
else if ( ! string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) & & string . IsNullOrEmpty ( datFile . Header . GetStringFieldValue ( Models . Metadata . Header . DescriptionKey ) ) )
2024-03-10 04:10:37 -04:00
{
2024-03-11 15:46:44 -04:00
datFile . Header . SetFieldValue < string? > ( Models . Metadata . Header . DescriptionKey , datFile . Header . GetStringFieldValue ( Models . Metadata . Header . NameKey ) ) ;
2024-03-10 04:10:37 -04:00
}
2020-12-10 11:28:11 -08:00
}
}
/// <summary>
/// Get if the DatFile has any writable items
/// </summary>
/// <param name="datFile">Current DatFile object to write from</param>
/// <returns>True if there are any writable items, false otherwise</returns>
2020-12-10 11:58:46 -08:00
private static bool HasWritable ( DatFile datFile )
2020-12-10 11:28:11 -08:00
{
// Force a statistics recheck, just in case
2025-01-14 15:46:42 -05:00
datFile . RecalculateStats ( ) ;
2020-12-10 11:28:11 -08:00
// If there's nothing there, abort
2025-01-12 23:15:30 -05:00
if ( datFile . DatStatistics . TotalCount = = 0 )
2020-12-10 11:28:11 -08:00
return false ;
2024-07-03 10:48:13 -04:00
// if (datFile.ItemsDB.DatStatistics.TotalCount == 0)
// return false;
2020-12-10 11:28:11 -08:00
// If every item is removed, abort
2025-01-12 23:15:30 -05:00
if ( datFile . DatStatistics . TotalCount = = datFile . DatStatistics . RemovedCount )
2020-12-10 11:28:11 -08:00
return false ;
2024-07-03 10:48:13 -04:00
// if (datFile.ItemsDB.DatStatistics.TotalCount == datFile.ItemsDB.DatStatistics.RemovedCount)
// return false;
2020-12-10 11:28:11 -08:00
return true ;
2024-02-28 22:54:56 -05:00
}
2025-01-29 13:25:36 -05:00
/// <summary>
/// Split a format flag into multiple distinct values
/// </summary>
/// <param name="datFormat">Combined DatFormat value to split</param>
/// <returns>List representing the individual flag values set</returns>
/// TODO: Consider making DatFormat a non-flag enum so this doesn't need to happen
private static List < DatFormat > SplitFormats ( DatFormat datFormat )
{
List < DatFormat > 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 ;
}
2020-12-10 11:28:11 -08:00
}
}