Support ancient .NET in DatFiles

This commit is contained in:
Matt Nadareski
2024-02-28 22:54:56 -05:00
parent e7c45c1f50
commit 2145245c31
38 changed files with 780 additions and 258 deletions

View File

@@ -123,19 +123,19 @@ namespace SabreTools.DatFiles
public void FillHeaderFromPath(string path, bool bare) public void FillHeaderFromPath(string path, bool bare)
{ {
// If the description is defined but not the name, set the name from the description // If the description is defined but not the name, set the name from the description
if (string.IsNullOrWhiteSpace(Header.Name) && !string.IsNullOrWhiteSpace(Header.Description)) if (string.IsNullOrEmpty(Header.Name) && !string.IsNullOrEmpty(Header.Description))
{ {
Header.Name = Header.Description; Header.Name = Header.Description;
} }
// If the name is defined but not the description, set the description from the name // If the name is defined but not the description, set the description from the name
else if (!string.IsNullOrWhiteSpace(Header.Name) && string.IsNullOrWhiteSpace(Header.Description)) else if (!string.IsNullOrEmpty(Header.Name) && string.IsNullOrEmpty(Header.Description))
{ {
Header.Description = Header.Name + (bare ? string.Empty : $" ({Header.Date})"); Header.Description = Header.Name + (bare ? string.Empty : $" ({Header.Date})");
} }
// If neither the name or description are defined, set them from the automatic values // If neither the name or description are defined, set them from the automatic values
else if (string.IsNullOrWhiteSpace(Header.Name) && string.IsNullOrWhiteSpace(Header.Description)) else if (string.IsNullOrEmpty(Header.Name) && string.IsNullOrEmpty(Header.Description))
{ {
string[] splitpath = path.TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar); string[] splitpath = path.TrimEnd(Path.DirectorySeparatorChar).Split(Path.DirectorySeparatorChar);
Header.Name = splitpath.Last(); Header.Name = splitpath.Last();
@@ -172,8 +172,8 @@ namespace SabreTools.DatFiles
{ {
// If the file has aboslutely no hashes, skip and log // If the file has aboslutely no hashes, skip and log
if (disk.ItemStatus != ItemStatus.Nodump if (disk.ItemStatus != ItemStatus.Nodump
&& string.IsNullOrWhiteSpace(disk.MD5) && string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
logger.Verbose($"Incomplete entry for '{disk.Name}' will be output as nodump"); logger.Verbose($"Incomplete entry for '{disk.Name}' will be output as nodump");
disk.ItemStatus = ItemStatus.Nodump; disk.ItemStatus = ItemStatus.Nodump;
@@ -184,10 +184,10 @@ namespace SabreTools.DatFiles
if (item.ItemType == ItemType.Media && item is Media media) if (item.ItemType == ItemType.Media && item is Media media)
{ {
// If the file has aboslutely no hashes, skip and log // If the file has aboslutely no hashes, skip and log
if (string.IsNullOrWhiteSpace(media.MD5) if (string.IsNullOrEmpty(media.MD5)
&& string.IsNullOrWhiteSpace(media.SHA1) && string.IsNullOrEmpty(media.SHA1)
&& string.IsNullOrWhiteSpace(media.SHA256) && string.IsNullOrEmpty(media.SHA256)
&& string.IsNullOrWhiteSpace(media.SpamSum)) && string.IsNullOrEmpty(media.SpamSum))
{ {
logger.Verbose($"Incomplete entry for '{media.Name}' will be output as nodump"); logger.Verbose($"Incomplete entry for '{media.Name}' will be output as nodump");
} }
@@ -205,7 +205,7 @@ namespace SabreTools.DatFiles
// If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info // If we have a rom and it's missing size AND the hashes match a 0-byte file, fill in the rest of the info
else if ((rom.Size == 0 || rom.Size == null) else if ((rom.Size == 0 || rom.Size == null)
&& (string.IsNullOrWhiteSpace(rom.CRC) || rom.HasZeroHash())) && (string.IsNullOrEmpty(rom.CRC) || rom.HasZeroHash()))
{ {
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually // TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
rom.Size = Constants.SizeZero; rom.Size = Constants.SizeZero;
@@ -262,7 +262,7 @@ namespace SabreTools.DatFiles
protected static string? CleanDate(string? input) protected static string? CleanDate(string? input)
{ {
// Null in, null out // Null in, null out
if (string.IsNullOrWhiteSpace(input)) if (string.IsNullOrEmpty(input))
return null; return null;
string date = string.Empty; string date = string.Empty;
@@ -409,7 +409,7 @@ namespace SabreTools.DatFiles
if (item.ItemType == ItemType.Disk && item is Disk disk) if (item.ItemType == ItemType.Disk && item is Disk disk)
{ {
// We can only write out if there's a SHA-1 // We can only write out if there's a SHA-1
if (!string.IsNullOrWhiteSpace(disk.SHA1)) if (!string.IsNullOrEmpty(disk.SHA1))
{ {
name = Utilities.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/'); name = Utilities.GetDepotPath(disk.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
item.SetName($"{pre}{name}{post}"); item.SetName($"{pre}{name}{post}");
@@ -418,7 +418,7 @@ namespace SabreTools.DatFiles
else if (item.ItemType == ItemType.Media && item is Media media) else if (item.ItemType == ItemType.Media && item is Media media)
{ {
// We can only write out if there's a SHA-1 // We can only write out if there's a SHA-1
if (!string.IsNullOrWhiteSpace(media.SHA1)) if (!string.IsNullOrEmpty(media.SHA1))
{ {
name = Utilities.GetDepotPath(media.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/'); name = Utilities.GetDepotPath(media.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
item.SetName($"{pre}{name}{post}"); item.SetName($"{pre}{name}{post}");
@@ -427,7 +427,7 @@ namespace SabreTools.DatFiles
else if (item.ItemType == ItemType.Rom && item is Rom rom) else if (item.ItemType == ItemType.Rom && item is Rom rom)
{ {
// We can only write out if there's a SHA-1 // We can only write out if there's a SHA-1
if (!string.IsNullOrWhiteSpace(rom.SHA1)) if (!string.IsNullOrEmpty(rom.SHA1))
{ {
name = Utilities.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/'); name = Utilities.GetDepotPath(rom.SHA1, Header.OutputDepot.Depth)?.Replace('\\', '/');
item.SetName($"{pre}{name}{post}"); item.SetName($"{pre}{name}{post}");
@@ -437,7 +437,7 @@ namespace SabreTools.DatFiles
return; return;
} }
if (!string.IsNullOrWhiteSpace(Header.ReplaceExtension) || Header.RemoveExtension) if (!string.IsNullOrEmpty(Header.ReplaceExtension) || Header.RemoveExtension)
{ {
if (Header.RemoveExtension) if (Header.RemoveExtension)
Header.ReplaceExtension = string.Empty; Header.ReplaceExtension = string.Empty;
@@ -450,7 +450,7 @@ namespace SabreTools.DatFiles
} }
} }
if (!string.IsNullOrWhiteSpace(Header.AddExtension)) if (!string.IsNullOrEmpty(Header.AddExtension))
name += Header.AddExtension; name += Header.AddExtension;
if (Header.UseRomName && Header.GameName) if (Header.UseRomName && Header.GameName)
@@ -597,7 +597,11 @@ namespace SabreTools.DatFiles
if (missingFields != null && missingFields.Count != 0) if (missingFields != null && missingFields.Count != 0)
{ {
string itemString = JsonConvert.SerializeObject(datItem, Formatting.None); string itemString = JsonConvert.SerializeObject(datItem, Formatting.None);
#if NET20 || NET35
logger?.Verbose($"Item '{itemString}' was skipped because it was missing required fields for {Header?.DatFormat}: {string.Join(", ", missingFields.Select(f => f.ToString()).ToArray())}");
#else
logger?.Verbose($"Item '{itemString}' was skipped because it was missing required fields for {Header?.DatFormat}: {string.Join(", ", missingFields)}"); logger?.Verbose($"Item '{itemString}' was skipped because it was missing required fields for {Header?.DatFormat}: {string.Join(", ", missingFields)}");
#endif
return true; return true;
} }

View File

@@ -656,46 +656,46 @@ namespace SabreTools.DatFiles
if (datHeader == null) if (datHeader == null)
return; return;
if (!string.IsNullOrWhiteSpace(datHeader.FileName)) if (!string.IsNullOrEmpty(datHeader.FileName))
FileName = datHeader.FileName; FileName = datHeader.FileName;
if (!string.IsNullOrWhiteSpace(datHeader.Name)) if (!string.IsNullOrEmpty(datHeader.Name))
Name = datHeader.Name; Name = datHeader.Name;
if (!string.IsNullOrWhiteSpace(datHeader.Description)) if (!string.IsNullOrEmpty(datHeader.Description))
Description = datHeader.Description; Description = datHeader.Description;
if (!string.IsNullOrWhiteSpace(datHeader.RootDir)) if (!string.IsNullOrEmpty(datHeader.RootDir))
RootDir = datHeader.RootDir; RootDir = datHeader.RootDir;
if (!string.IsNullOrWhiteSpace(datHeader.Category)) if (!string.IsNullOrEmpty(datHeader.Category))
Category = datHeader.Category; Category = datHeader.Category;
if (!string.IsNullOrWhiteSpace(datHeader.Version)) if (!string.IsNullOrEmpty(datHeader.Version))
Version = datHeader.Version; Version = datHeader.Version;
if (!string.IsNullOrWhiteSpace(datHeader.Date)) if (!string.IsNullOrEmpty(datHeader.Date))
Date = datHeader.Date; Date = datHeader.Date;
if (!string.IsNullOrWhiteSpace(datHeader.Author)) if (!string.IsNullOrEmpty(datHeader.Author))
Author = datHeader.Author; Author = datHeader.Author;
if (!string.IsNullOrWhiteSpace(datHeader.Email)) if (!string.IsNullOrEmpty(datHeader.Email))
Email = datHeader.Email; Email = datHeader.Email;
if (!string.IsNullOrWhiteSpace(datHeader.Homepage)) if (!string.IsNullOrEmpty(datHeader.Homepage))
Homepage = datHeader.Homepage; Homepage = datHeader.Homepage;
if (!string.IsNullOrWhiteSpace(datHeader.Url)) if (!string.IsNullOrEmpty(datHeader.Url))
Url = datHeader.Url; Url = datHeader.Url;
if (!string.IsNullOrWhiteSpace(datHeader.Comment)) if (!string.IsNullOrEmpty(datHeader.Comment))
Comment = datHeader.Comment; Comment = datHeader.Comment;
if (!string.IsNullOrWhiteSpace(datHeader.HeaderSkipper)) if (!string.IsNullOrEmpty(datHeader.HeaderSkipper))
HeaderSkipper = datHeader.HeaderSkipper; HeaderSkipper = datHeader.HeaderSkipper;
if (!string.IsNullOrWhiteSpace(datHeader.Type)) if (!string.IsNullOrEmpty(datHeader.Type))
Type = datHeader.Type; Type = datHeader.Type;
if (datHeader.ForceMerging != MergingFlag.None) if (datHeader.ForceMerging != MergingFlag.None)
@@ -710,16 +710,16 @@ namespace SabreTools.DatFiles
if (datHeader.DatFormat != 0x00) if (datHeader.DatFormat != 0x00)
DatFormat = datHeader.DatFormat; DatFormat = datHeader.DatFormat;
if (!string.IsNullOrWhiteSpace(datHeader.Prefix)) if (!string.IsNullOrEmpty(datHeader.Prefix))
Prefix = datHeader.Prefix; Prefix = datHeader.Prefix;
if (!string.IsNullOrWhiteSpace(datHeader.Postfix)) if (!string.IsNullOrEmpty(datHeader.Postfix))
Postfix = datHeader.Postfix; Postfix = datHeader.Postfix;
if (!string.IsNullOrWhiteSpace(datHeader.AddExtension)) if (!string.IsNullOrEmpty(datHeader.AddExtension))
AddExtension = datHeader.AddExtension; AddExtension = datHeader.AddExtension;
if (!string.IsNullOrWhiteSpace(datHeader.ReplaceExtension)) if (!string.IsNullOrEmpty(datHeader.ReplaceExtension))
ReplaceExtension = datHeader.ReplaceExtension; ReplaceExtension = datHeader.ReplaceExtension;
RemoveExtension = datHeader.RemoveExtension; RemoveExtension = datHeader.RemoveExtension;
@@ -757,7 +757,11 @@ namespace SabreTools.DatFiles
#region .csv #region .csv
// CSV // CSV
#if NETFRAMEWORK
if ((DatFormat & DatFormat.CSV) != 0)
#else
if (DatFormat.HasFlag(DatFormat.CSV)) if (DatFormat.HasFlag(DatFormat.CSV))
#endif
{ {
outfileNames.Add(DatFormat.CSV, CreateOutFileNamesHelper(outDir, ".csv", overwrite)); outfileNames.Add(DatFormat.CSV, CreateOutFileNamesHelper(outDir, ".csv", overwrite));
usedExtensions.Add(".csv"); usedExtensions.Add(".csv");
@@ -768,14 +772,22 @@ namespace SabreTools.DatFiles
#region .dat #region .dat
// ClrMamePro // ClrMamePro
#if NETFRAMEWORK
if ((DatFormat & DatFormat.ClrMamePro) != 0)
#else
if (DatFormat.HasFlag(DatFormat.ClrMamePro)) if (DatFormat.HasFlag(DatFormat.ClrMamePro))
#endif
{ {
outfileNames.Add(DatFormat.ClrMamePro, CreateOutFileNamesHelper(outDir, ".dat", overwrite)); outfileNames.Add(DatFormat.ClrMamePro, CreateOutFileNamesHelper(outDir, ".dat", overwrite));
usedExtensions.Add(".dat"); usedExtensions.Add(".dat");
}; };
// RomCenter // RomCenter
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RomCenter) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RomCenter)) if (DatFormat.HasFlag(DatFormat.RomCenter))
#endif
{ {
if (usedExtensions.Contains(".dat")) if (usedExtensions.Contains(".dat"))
{ {
@@ -790,7 +802,11 @@ namespace SabreTools.DatFiles
} }
// DOSCenter // DOSCenter
#if NETFRAMEWORK
if ((DatFormat & DatFormat.DOSCenter) != 0)
#else
if (DatFormat.HasFlag(DatFormat.DOSCenter)) if (DatFormat.HasFlag(DatFormat.DOSCenter))
#endif
{ {
if (usedExtensions.Contains(".dat")) if (usedExtensions.Contains(".dat"))
{ {
@@ -809,7 +825,11 @@ namespace SabreTools.DatFiles
#region .json #region .json
// JSON // JSON
#if NETFRAMEWORK
if ((DatFormat & DatFormat.SabreJSON) != 0)
#else
if (DatFormat.HasFlag(DatFormat.SabreJSON)) if (DatFormat.HasFlag(DatFormat.SabreJSON))
#endif
{ {
outfileNames.Add(DatFormat.SabreJSON, CreateOutFileNamesHelper(outDir, ".json", overwrite)); outfileNames.Add(DatFormat.SabreJSON, CreateOutFileNamesHelper(outDir, ".json", overwrite));
usedExtensions.Add(".json"); usedExtensions.Add(".json");
@@ -820,7 +840,11 @@ namespace SabreTools.DatFiles
#region .md5 #region .md5
// Redump MD5 // Redump MD5
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpMD5) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpMD5)) if (DatFormat.HasFlag(DatFormat.RedumpMD5))
#endif
{ {
outfileNames.Add(DatFormat.RedumpMD5, CreateOutFileNamesHelper(outDir, ".md5", overwrite)); outfileNames.Add(DatFormat.RedumpMD5, CreateOutFileNamesHelper(outDir, ".md5", overwrite));
usedExtensions.Add(".md5"); usedExtensions.Add(".md5");
@@ -831,7 +855,11 @@ namespace SabreTools.DatFiles
#region .sfv #region .sfv
// Redump SFV // Redump SFV
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSFV) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSFV)) if (DatFormat.HasFlag(DatFormat.RedumpSFV))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSFV, CreateOutFileNamesHelper(outDir, ".sfv", overwrite)); outfileNames.Add(DatFormat.RedumpSFV, CreateOutFileNamesHelper(outDir, ".sfv", overwrite));
usedExtensions.Add(".sfv"); usedExtensions.Add(".sfv");
@@ -842,7 +870,11 @@ namespace SabreTools.DatFiles
#region .sha1 #region .sha1
// Redump SHA-1 // Redump SHA-1
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSHA1) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSHA1)) if (DatFormat.HasFlag(DatFormat.RedumpSHA1))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSHA1, CreateOutFileNamesHelper(outDir, ".sha1", overwrite)); outfileNames.Add(DatFormat.RedumpSHA1, CreateOutFileNamesHelper(outDir, ".sha1", overwrite));
usedExtensions.Add(".sha1"); usedExtensions.Add(".sha1");
@@ -853,7 +885,11 @@ namespace SabreTools.DatFiles
#region .sha256 #region .sha256
// Redump SHA-256 // Redump SHA-256
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSHA256) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSHA256)) if (DatFormat.HasFlag(DatFormat.RedumpSHA256))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSHA256, CreateOutFileNamesHelper(outDir, ".sha256", overwrite)); outfileNames.Add(DatFormat.RedumpSHA256, CreateOutFileNamesHelper(outDir, ".sha256", overwrite));
usedExtensions.Add(".sha256"); usedExtensions.Add(".sha256");
@@ -864,7 +900,11 @@ namespace SabreTools.DatFiles
#region .sha384 #region .sha384
// Redump SHA-384 // Redump SHA-384
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSHA384) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSHA384)) if (DatFormat.HasFlag(DatFormat.RedumpSHA384))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSHA384, CreateOutFileNamesHelper(outDir, ".sha384", overwrite)); outfileNames.Add(DatFormat.RedumpSHA384, CreateOutFileNamesHelper(outDir, ".sha384", overwrite));
usedExtensions.Add(".sha384"); usedExtensions.Add(".sha384");
@@ -875,7 +915,11 @@ namespace SabreTools.DatFiles
#region .sha512 #region .sha512
// Redump SHA-512 // Redump SHA-512
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSHA512) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSHA512)) if (DatFormat.HasFlag(DatFormat.RedumpSHA512))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSHA512, CreateOutFileNamesHelper(outDir, ".sha512", overwrite)); outfileNames.Add(DatFormat.RedumpSHA512, CreateOutFileNamesHelper(outDir, ".sha512", overwrite));
usedExtensions.Add(".sha512"); usedExtensions.Add(".sha512");
@@ -886,7 +930,11 @@ namespace SabreTools.DatFiles
#region .spamsum #region .spamsum
// Redump SpamSum // Redump SpamSum
#if NETFRAMEWORK
if ((DatFormat & DatFormat.RedumpSpamSum) != 0)
#else
if (DatFormat.HasFlag(DatFormat.RedumpSpamSum)) if (DatFormat.HasFlag(DatFormat.RedumpSpamSum))
#endif
{ {
outfileNames.Add(DatFormat.RedumpSpamSum, CreateOutFileNamesHelper(outDir, ".spamsum", overwrite)); outfileNames.Add(DatFormat.RedumpSpamSum, CreateOutFileNamesHelper(outDir, ".spamsum", overwrite));
usedExtensions.Add(".spamsum"); usedExtensions.Add(".spamsum");
@@ -897,7 +945,11 @@ namespace SabreTools.DatFiles
#region .ssv #region .ssv
// SSV // SSV
#if NETFRAMEWORK
if ((DatFormat & DatFormat.SSV) != 0)
#else
if (DatFormat.HasFlag(DatFormat.SSV)) if (DatFormat.HasFlag(DatFormat.SSV))
#endif
{ {
outfileNames.Add(DatFormat.SSV, CreateOutFileNamesHelper(outDir, ".ssv", overwrite)); outfileNames.Add(DatFormat.SSV, CreateOutFileNamesHelper(outDir, ".ssv", overwrite));
usedExtensions.Add(".ssv"); usedExtensions.Add(".ssv");
@@ -908,7 +960,11 @@ namespace SabreTools.DatFiles
#region .tsv #region .tsv
// TSV // TSV
#if NETFRAMEWORK
if ((DatFormat & DatFormat.TSV) != 0)
#else
if (DatFormat.HasFlag(DatFormat.TSV)) if (DatFormat.HasFlag(DatFormat.TSV))
#endif
{ {
outfileNames.Add(DatFormat.TSV, CreateOutFileNamesHelper(outDir, ".tsv", overwrite)); outfileNames.Add(DatFormat.TSV, CreateOutFileNamesHelper(outDir, ".tsv", overwrite));
usedExtensions.Add(".tsv"); usedExtensions.Add(".tsv");
@@ -919,14 +975,22 @@ namespace SabreTools.DatFiles
#region .txt #region .txt
// AttractMode // AttractMode
#if NETFRAMEWORK
if ((DatFormat & DatFormat.AttractMode) != 0)
#else
if (DatFormat.HasFlag(DatFormat.AttractMode)) if (DatFormat.HasFlag(DatFormat.AttractMode))
#endif
{ {
outfileNames.Add(DatFormat.AttractMode, CreateOutFileNamesHelper(outDir, ".txt", overwrite)); outfileNames.Add(DatFormat.AttractMode, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
usedExtensions.Add(".txt"); usedExtensions.Add(".txt");
} }
// MAME Listroms // MAME Listroms
#if NETFRAMEWORK
if ((DatFormat & DatFormat.Listrom) != 0)
#else
if (DatFormat.HasFlag(DatFormat.Listrom)) if (DatFormat.HasFlag(DatFormat.Listrom))
#endif
{ {
if (usedExtensions.Contains(".txt")) if (usedExtensions.Contains(".txt"))
{ {
@@ -941,7 +1005,11 @@ namespace SabreTools.DatFiles
} }
// Missfile // Missfile
#if NETFRAMEWORK
if ((DatFormat & DatFormat.MissFile) != 0)
#else
if (DatFormat.HasFlag(DatFormat.MissFile)) if (DatFormat.HasFlag(DatFormat.MissFile))
#endif
{ {
if (usedExtensions.Contains(".txt")) if (usedExtensions.Contains(".txt"))
{ {
@@ -956,7 +1024,11 @@ namespace SabreTools.DatFiles
} }
// Everdrive SMDB // Everdrive SMDB
#if NETFRAMEWORK
if ((DatFormat & DatFormat.EverdriveSMDB) != 0)
#else
if (DatFormat.HasFlag(DatFormat.EverdriveSMDB)) if (DatFormat.HasFlag(DatFormat.EverdriveSMDB))
#endif
{ {
if (usedExtensions.Contains(".txt")) if (usedExtensions.Contains(".txt"))
{ {
@@ -975,19 +1047,31 @@ namespace SabreTools.DatFiles
#region .xml #region .xml
// Logiqx XML // Logiqx XML
#if NETFRAMEWORK
if ((DatFormat & DatFormat.Logiqx) != 0)
#else
if (DatFormat.HasFlag(DatFormat.Logiqx)) if (DatFormat.HasFlag(DatFormat.Logiqx))
#endif
{ {
outfileNames.Add(DatFormat.Logiqx, CreateOutFileNamesHelper(outDir, ".xml", overwrite)); outfileNames.Add(DatFormat.Logiqx, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
usedExtensions.Add(".xml"); usedExtensions.Add(".xml");
} }
#if NETFRAMEWORK
if ((DatFormat & DatFormat.LogiqxDeprecated) != 0)
#else
if (DatFormat.HasFlag(DatFormat.LogiqxDeprecated)) if (DatFormat.HasFlag(DatFormat.LogiqxDeprecated))
#endif
{ {
outfileNames.Add(DatFormat.LogiqxDeprecated, CreateOutFileNamesHelper(outDir, ".xml", overwrite)); outfileNames.Add(DatFormat.LogiqxDeprecated, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
usedExtensions.Add(".xml"); usedExtensions.Add(".xml");
} }
// SabreDAT // SabreDAT
#if NETFRAMEWORK
if ((DatFormat & DatFormat.SabreXML) != 0)
#else
if (DatFormat.HasFlag(DatFormat.SabreXML)) if (DatFormat.HasFlag(DatFormat.SabreXML))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1002,7 +1086,11 @@ namespace SabreTools.DatFiles
} }
// Software List // Software List
#if NETFRAMEWORK
if ((DatFormat & DatFormat.SoftwareList) != 0)
#else
if (DatFormat.HasFlag(DatFormat.SoftwareList)) if (DatFormat.HasFlag(DatFormat.SoftwareList))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1017,7 +1105,11 @@ namespace SabreTools.DatFiles
} }
// MAME Listxml // MAME Listxml
#if NETFRAMEWORK
if ((DatFormat & DatFormat.Listxml) != 0)
#else
if (DatFormat.HasFlag(DatFormat.Listxml)) if (DatFormat.HasFlag(DatFormat.Listxml))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1032,7 +1124,11 @@ namespace SabreTools.DatFiles
} }
// OfflineList // OfflineList
#if NETFRAMEWORK
if ((DatFormat & DatFormat.OfflineList) != 0)
#else
if (DatFormat.HasFlag(DatFormat.OfflineList)) if (DatFormat.HasFlag(DatFormat.OfflineList))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1047,7 +1143,11 @@ namespace SabreTools.DatFiles
} }
// openMSX // openMSX
#if NETFRAMEWORK
if ((DatFormat & DatFormat.OpenMSX) != 0)
#else
if (DatFormat.HasFlag(DatFormat.OpenMSX)) if (DatFormat.HasFlag(DatFormat.OpenMSX))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1062,7 +1162,11 @@ namespace SabreTools.DatFiles
} }
// Archive.org // Archive.org
#if NETFRAMEWORK
if ((DatFormat & DatFormat.ArchiveDotOrg) != 0)
#else
if (DatFormat.HasFlag(DatFormat.ArchiveDotOrg)) if (DatFormat.HasFlag(DatFormat.ArchiveDotOrg))
#endif
{ {
if (usedExtensions.Contains(".xml")) if (usedExtensions.Contains(".xml"))
{ {
@@ -1090,7 +1194,7 @@ namespace SabreTools.DatFiles
/// <returns>String containing the new filename</returns> /// <returns>String containing the new filename</returns>
private string CreateOutFileNamesHelper(string outDir, string extension, bool overwrite) private string CreateOutFileNamesHelper(string outDir, string extension, bool overwrite)
{ {
string? filename = string.IsNullOrWhiteSpace(FileName) ? Description : FileName; string? filename = string.IsNullOrEmpty(FileName) ? Description : FileName;
// Strip off the extension if it's a holdover from the DAT // Strip off the extension if it's a holdover from the DAT
if (Utilities.HasValidDatExtension(filename)) if (Utilities.HasValidDatExtension(filename))

View File

@@ -41,21 +41,21 @@ namespace SabreTools.DatFiles.Formats
private static (Machine?, string?) DeriveMachine(string? filename) private static (Machine?, string?) DeriveMachine(string? filename)
{ {
// If the filename is missing, we can't do anything // If the filename is missing, we can't do anything
if (string.IsNullOrWhiteSpace(filename)) if (string.IsNullOrEmpty(filename))
return (null, null); return (null, null);
string machineName = Path.GetFileNameWithoutExtension(filename); string machineName = Path.GetFileNameWithoutExtension(filename);
if (filename.Contains('/')) if (filename.Contains('/'))
{ {
string[] split = filename.Split('/'); string[] split = filename!.Split('/');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
else if (filename.Contains('\\')) else if (filename.Contains('\\'))
{ {
string[] split = filename.Split('\\'); string[] split = filename!.Split('\\');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
var machine = new Machine { Name = machineName }; var machine = new Machine { Name = machineName };
@@ -69,11 +69,7 @@ namespace SabreTools.DatFiles.Formats
/// <param name="filename">Name of the file to be parsed</param> /// <param name="filename">Name of the file to be parsed</param>
/// <param name="indexId">Index ID for the DAT</param> /// <param name="indexId">Index ID for the DAT</param>
/// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param> /// <param name="statsOnly">True to only add item statistics while parsing, false otherwise</param>
#if NET48
private void ConvertFiles(Models.ArchiveDotOrg.File[]? files, string filename, int indexId, bool statsOnly)
#else
private void ConvertFiles(Models.ArchiveDotOrg.File?[]? files, string filename, int indexId, bool statsOnly) private void ConvertFiles(Models.ArchiveDotOrg.File?[]? files, string filename, int indexId, bool statsOnly)
#endif
{ {
// If the files array is missing, we can't do anything // If the files array is missing, we can't do anything
if (files == null || !files.Any()) if (files == null || !files.Any())

View File

@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
@@ -35,9 +35,9 @@ namespace SabreTools.DatFiles.Formats
case Rom rom: case Rom rom:
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC) if (string.IsNullOrEmpty(rom.CRC)
&& string.IsNullOrWhiteSpace(rom.MD5) && string.IsNullOrEmpty(rom.MD5)
&& string.IsNullOrWhiteSpace(rom.SHA1)) && string.IsNullOrEmpty(rom.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }

View File

@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
return missingFields; return missingFields;

View File

@@ -41,60 +41,60 @@ namespace SabreTools.DatFiles.Formats
switch (datItem) switch (datItem)
{ {
case Release release: case Release release:
if (string.IsNullOrWhiteSpace(release.Name)) if (string.IsNullOrEmpty(release.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(release.Region)) if (string.IsNullOrEmpty(release.Region))
missingFields.Add(DatItemField.Region); missingFields.Add(DatItemField.Region);
break; break;
case BiosSet biosset: case BiosSet biosset:
if (string.IsNullOrWhiteSpace(biosset.Name)) if (string.IsNullOrEmpty(biosset.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(biosset.Description)) if (string.IsNullOrEmpty(biosset.Description))
missingFields.Add(DatItemField.Description); missingFields.Add(DatItemField.Description);
break; break;
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.Name)) if (string.IsNullOrEmpty(rom.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC) if (string.IsNullOrEmpty(rom.CRC)
&& string.IsNullOrWhiteSpace(rom.MD5) && string.IsNullOrEmpty(rom.MD5)
&& string.IsNullOrWhiteSpace(rom.SHA1) && string.IsNullOrEmpty(rom.SHA1)
&& string.IsNullOrWhiteSpace(rom.SHA256) && string.IsNullOrEmpty(rom.SHA256)
&& string.IsNullOrWhiteSpace(rom.SHA384) && string.IsNullOrEmpty(rom.SHA384)
&& string.IsNullOrWhiteSpace(rom.SHA512) && string.IsNullOrEmpty(rom.SHA512)
&& string.IsNullOrWhiteSpace(rom.SpamSum)) && string.IsNullOrEmpty(rom.SpamSum))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case Disk disk: case Disk disk:
if (string.IsNullOrWhiteSpace(disk.Name)) if (string.IsNullOrEmpty(disk.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(disk.MD5) if (string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case Sample sample: case Sample sample:
if (string.IsNullOrWhiteSpace(sample.Name)) if (string.IsNullOrEmpty(sample.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Archive archive: case Archive archive:
if (string.IsNullOrWhiteSpace(archive.Name)) if (string.IsNullOrEmpty(archive.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Chip chip: case Chip chip:
if (!chip.ChipTypeSpecified) if (!chip.ChipTypeSpecified)
missingFields.Add(DatItemField.ChipType); missingFields.Add(DatItemField.ChipType);
if (string.IsNullOrWhiteSpace(chip.Name)) if (string.IsNullOrEmpty(chip.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
@@ -118,7 +118,7 @@ namespace SabreTools.DatFiles.Formats
break; break;
case DipSwitch dipswitch: case DipSwitch dipswitch:
if (string.IsNullOrWhiteSpace(dipswitch.Name)) if (string.IsNullOrEmpty(dipswitch.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;

View File

@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
@@ -35,9 +35,9 @@ namespace SabreTools.DatFiles.Formats
case Rom rom: case Rom rom:
if (!rom.SizeSpecified) if (!rom.SizeSpecified)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
// if (string.IsNullOrWhiteSpace(rom.Date)) // if (string.IsNullOrEmpty(rom.Date))
// missingFields.Add(DatItemField.Date); // missingFields.Add(DatItemField.Date);
if (string.IsNullOrWhiteSpace(rom.CRC)) if (string.IsNullOrEmpty(rom.CRC))
missingFields.Add(DatItemField.CRC); missingFields.Add(DatItemField.CRC);
break; break;
} }

View File

@@ -41,21 +41,21 @@ namespace SabreTools.DatFiles.Formats
private static (Machine?, string?) DeriveMachine(string? filename) private static (Machine?, string?) DeriveMachine(string? filename)
{ {
// If the filename is missing, we can't do anything // If the filename is missing, we can't do anything
if (string.IsNullOrWhiteSpace(filename)) if (string.IsNullOrEmpty(filename))
return (null, null); return (null, null);
string machineName = Path.GetFileNameWithoutExtension(filename); string machineName = Path.GetFileNameWithoutExtension(filename);
if (filename.Contains('/')) if (filename.Contains('/'))
{ {
string[] split = filename.Split('/'); string[] split = filename!.Split('/');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
else if (filename.Contains('\\')) else if (filename.Contains('\\'))
{ {
string[] split = filename.Split('\\'); string[] split = filename!.Split('\\');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
var machine = new Machine { Name = machineName }; var machine = new Machine { Name = machineName };

View File

@@ -27,19 +27,19 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
{ {
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.SHA256)) if (string.IsNullOrEmpty(rom.SHA256))
missingFields.Add(DatItemField.SHA256); missingFields.Add(DatItemField.SHA256);
if (string.IsNullOrWhiteSpace(rom.SHA1)) if (string.IsNullOrEmpty(rom.SHA1))
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
if (string.IsNullOrWhiteSpace(rom.MD5)) if (string.IsNullOrEmpty(rom.MD5))
missingFields.Add(DatItemField.MD5); missingFields.Add(DatItemField.MD5);
if (string.IsNullOrWhiteSpace(rom.CRC)) if (string.IsNullOrEmpty(rom.CRC))
missingFields.Add(DatItemField.CRC); missingFields.Add(DatItemField.CRC);
break; break;
} }

View File

@@ -63,21 +63,21 @@ namespace SabreTools.DatFiles.Formats
private static (Machine?, string?) DeriveMachine(string? filename) private static (Machine?, string?) DeriveMachine(string? filename)
{ {
// If the filename is missing, we can't do anything // If the filename is missing, we can't do anything
if (string.IsNullOrWhiteSpace(filename)) if (string.IsNullOrEmpty(filename))
return (null, null); return (null, null);
string machineName = Path.GetFileNameWithoutExtension(filename); string machineName = Path.GetFileNameWithoutExtension(filename);
if (filename.Contains('/')) if (filename.Contains('/'))
{ {
string[] split = filename.Split('/'); string[] split = filename!.Split('/');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
else if (filename.Contains('\\')) else if (filename.Contains('\\'))
{ {
string[] split = filename.Split('\\'); string[] split = filename!.Split('\\');
machineName = split[0]; machineName = split[0];
filename = filename[(machineName.Length + 1)..]; filename = filename.Substring(machineName.Length + 1);
} }
var machine = new Machine { Name = machineName }; var machine = new Machine { Name = machineName };
@@ -92,11 +92,11 @@ namespace SabreTools.DatFiles.Formats
private static ItemType DeriveItemType(string? filename) private static ItemType DeriveItemType(string? filename)
{ {
// If the filename is missing, we can't do anything // If the filename is missing, we can't do anything
if (string.IsNullOrWhiteSpace(filename)) if (string.IsNullOrEmpty(filename))
return ItemType.NULL; return ItemType.NULL;
// If we end in the CHD extension // If we end in the CHD extension
if (filename.EndsWith(".chd", StringComparison.OrdinalIgnoreCase)) if (filename!.EndsWith(".chd", StringComparison.OrdinalIgnoreCase))
return ItemType.Disk; return ItemType.Disk;
// If we end in an Aaruformat extension // If we end in an Aaruformat extension

View File

@@ -30,7 +30,7 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
// Check hash linked to specific Hashfile type // Check hash linked to specific Hashfile type

View File

@@ -67,7 +67,7 @@ namespace SabreTools.DatFiles.Formats
// Create the machine // Create the machine
Machine machine; Machine machine;
if (!string.IsNullOrWhiteSpace(set.Device)) if (!string.IsNullOrEmpty(set.Device))
{ {
machine = new Machine machine = new Machine
{ {
@@ -75,7 +75,7 @@ namespace SabreTools.DatFiles.Formats
MachineType = MachineType.Device, MachineType = MachineType.Device,
}; };
} }
else if (!string.IsNullOrWhiteSpace(set.Driver)) else if (!string.IsNullOrEmpty(set.Driver))
{ {
machine = new Machine machine = new Machine
{ {
@@ -111,8 +111,8 @@ namespace SabreTools.DatFiles.Formats
if (row.Size == null if (row.Size == null
&& !row.NoGoodDumpKnown && !row.NoGoodDumpKnown
&& !row.Bad && !row.Bad
&& (!string.IsNullOrWhiteSpace(row.MD5) && (!string.IsNullOrEmpty(row.MD5)
|| !string.IsNullOrWhiteSpace(row.SHA1))) || !string.IsNullOrEmpty(row.SHA1)))
{ {
var disk = new Disk var disk = new Disk
{ {
@@ -126,7 +126,7 @@ namespace SabreTools.DatFiles.Formats
}, },
}; };
if (!string.IsNullOrWhiteSpace(row.MD5)) if (!string.IsNullOrEmpty(row.MD5))
disk.MD5 = row.MD5; disk.MD5 = row.MD5;
else else
disk.SHA1 = row.SHA1; disk.SHA1 = row.SHA1;
@@ -165,8 +165,8 @@ namespace SabreTools.DatFiles.Formats
else if (row.Size == null else if (row.Size == null
&& !row.NoGoodDumpKnown && !row.NoGoodDumpKnown
&& row.Bad && row.Bad
&& (!string.IsNullOrWhiteSpace(row.MD5) && (!string.IsNullOrEmpty(row.MD5)
|| !string.IsNullOrWhiteSpace(row.SHA1))) || !string.IsNullOrEmpty(row.SHA1)))
{ {
var disk = new Disk var disk = new Disk
{ {
@@ -180,7 +180,7 @@ namespace SabreTools.DatFiles.Formats
}, },
}; };
if (!string.IsNullOrWhiteSpace(row.MD5)) if (!string.IsNullOrEmpty(row.MD5))
disk.MD5 = row.MD5; disk.MD5 = row.MD5;
else else
disk.SHA1 = row.SHA1; disk.SHA1 = row.SHA1;

View File

@@ -28,14 +28,14 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
{ {
case Disk disk: case Disk disk:
if (string.IsNullOrWhiteSpace(disk.MD5) if (string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
@@ -44,9 +44,9 @@ namespace SabreTools.DatFiles.Formats
case Rom rom: case Rom rom:
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC)) if (string.IsNullOrEmpty(rom.CRC))
missingFields.Add(DatItemField.CRC); missingFields.Add(DatItemField.CRC);
if (string.IsNullOrWhiteSpace(rom.SHA1)) if (string.IsNullOrEmpty(rom.SHA1))
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
break; break;
} }
@@ -116,8 +116,13 @@ namespace SabreTools.DatFiles.Formats
var set = new Models.Listrom.Set var set = new Models.Listrom.Set
{ {
#if NETFRAMEWORK
Driver = (items[0]!.Machine!.MachineType & MachineType.Device) != 0 ? items[0]!.Machine!.Name : null,
Device = (items[0]!.Machine!.MachineType & MachineType.Device) != 0 ? items[0]!.Machine!.Name : null,
#else
Driver = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null, Driver = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
Device = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null, Device = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
#endif
}; };
// Loop through and convert the items to respective lists // Loop through and convert the items to respective lists
@@ -177,7 +182,7 @@ namespace SabreTools.DatFiles.Formats
Bad = true, Bad = true,
}; };
if (!string.IsNullOrWhiteSpace(disk.MD5)) if (!string.IsNullOrEmpty(disk.MD5))
row.MD5 = disk.MD5; row.MD5 = disk.MD5;
else else
row.SHA1 = disk.SHA1; row.SHA1 = disk.SHA1;
@@ -191,7 +196,7 @@ namespace SabreTools.DatFiles.Formats
Name = disk.Name, Name = disk.Name,
}; };
if (!string.IsNullOrWhiteSpace(disk.MD5)) if (!string.IsNullOrEmpty(disk.MD5))
row.MD5 = disk.MD5; row.MD5 = disk.MD5;
else else
row.SHA1 = disk.SHA1; row.SHA1 = disk.SHA1;

View File

@@ -48,46 +48,46 @@ namespace SabreTools.DatFiles.Formats
switch (datItem) switch (datItem)
{ {
case BiosSet biosset: case BiosSet biosset:
if (string.IsNullOrWhiteSpace(biosset.Name)) if (string.IsNullOrEmpty(biosset.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(biosset.Description)) if (string.IsNullOrEmpty(biosset.Description))
missingFields.Add(DatItemField.Description); missingFields.Add(DatItemField.Description);
break; break;
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.Name)) if (string.IsNullOrEmpty(rom.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC) if (string.IsNullOrEmpty(rom.CRC)
&& string.IsNullOrWhiteSpace(rom.SHA1)) && string.IsNullOrEmpty(rom.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case Disk disk: case Disk disk:
if (string.IsNullOrWhiteSpace(disk.Name)) if (string.IsNullOrEmpty(disk.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(disk.MD5) if (string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case DeviceReference deviceref: case DeviceReference deviceref:
if (string.IsNullOrWhiteSpace(deviceref.Name)) if (string.IsNullOrEmpty(deviceref.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Sample sample: case Sample sample:
if (string.IsNullOrWhiteSpace(sample.Name)) if (string.IsNullOrEmpty(sample.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Chip chip: case Chip chip:
if (string.IsNullOrWhiteSpace(chip.Name)) if (string.IsNullOrEmpty(chip.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (!chip.ChipTypeSpecified) if (!chip.ChipTypeSpecified)
missingFields.Add(DatItemField.ChipType); missingFields.Add(DatItemField.ChipType);
@@ -111,26 +111,26 @@ namespace SabreTools.DatFiles.Formats
break; break;
case DipSwitch dipswitch: case DipSwitch dipswitch:
if (string.IsNullOrWhiteSpace(dipswitch.Name)) if (string.IsNullOrEmpty(dipswitch.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(dipswitch.Tag)) if (string.IsNullOrEmpty(dipswitch.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
break; break;
case Configuration configuration: case Configuration configuration:
if (string.IsNullOrWhiteSpace(configuration.Name)) if (string.IsNullOrEmpty(configuration.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(configuration.Tag)) if (string.IsNullOrEmpty(configuration.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
break; break;
case Port port: case Port port:
if (string.IsNullOrWhiteSpace(port.Tag)) if (string.IsNullOrEmpty(port.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
break; break;
case Adjuster adjuster: case Adjuster adjuster:
if (string.IsNullOrWhiteSpace(adjuster.Name)) if (string.IsNullOrEmpty(adjuster.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
@@ -156,21 +156,21 @@ namespace SabreTools.DatFiles.Formats
break; break;
case Slot slot: case Slot slot:
if (string.IsNullOrWhiteSpace(slot.Name)) if (string.IsNullOrEmpty(slot.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case DatItems.Formats.SoftwareList softwarelist: case DatItems.Formats.SoftwareList softwarelist:
if (string.IsNullOrWhiteSpace(softwarelist.Tag)) if (string.IsNullOrEmpty(softwarelist.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
if (string.IsNullOrWhiteSpace(softwarelist.Name)) if (string.IsNullOrEmpty(softwarelist.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (!softwarelist.StatusSpecified) if (!softwarelist.StatusSpecified)
missingFields.Add(DatItemField.SoftwareListStatus); missingFields.Add(DatItemField.SoftwareListStatus);
break; break;
case RamOption ramoption: case RamOption ramoption:
if (string.IsNullOrWhiteSpace(ramoption.Name)) if (string.IsNullOrEmpty(ramoption.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
} }
@@ -384,12 +384,21 @@ namespace SabreTools.DatFiles.Formats
History = machine.History, History = machine.History,
}; };
#if NETFRAMEWORK
if ((machine.MachineType & MachineType.Bios) != 0)
game.IsBios = "yes";
if ((machine.MachineType & MachineType.Device) != 0)
game.IsDevice = "yes";
if ((machine.MachineType & MachineType.Mechanical) != 0)
game.IsMechanical = "yes";
#else
if (machine.MachineType.HasFlag(MachineType.Bios)) if (machine.MachineType.HasFlag(MachineType.Bios))
game.IsBios = "yes"; game.IsBios = "yes";
if (machine.MachineType.HasFlag(MachineType.Device)) if (machine.MachineType.HasFlag(MachineType.Device))
game.IsDevice = "yes"; game.IsDevice = "yes";
if (machine.MachineType.HasFlag(MachineType.Mechanical)) if (machine.MachineType.HasFlag(MachineType.Mechanical))
game.IsMechanical = "yes"; game.IsMechanical = "yes";
#endif
return game; return game;
} }

View File

@@ -226,7 +226,7 @@ namespace SabreTools.DatFiles.Formats
Publisher = game.Publisher, Publisher = game.Publisher,
}; };
if (!string.IsNullOrWhiteSpace(dirname)) if (!string.IsNullOrEmpty(dirname))
machine.Name = $"{dirname}/{machine.Name}"; machine.Name = $"{dirname}/{machine.Name}";
if (game.IsBios.AsYesNo() == true) if (game.IsBios.AsYesNo() == true)
@@ -236,10 +236,17 @@ namespace SabreTools.DatFiles.Formats
if (game.IsMechanical.AsYesNo() == true) if (game.IsMechanical.AsYesNo() == true)
machine.MachineType |= MachineType.Mechanical; machine.MachineType |= MachineType.Mechanical;
#if NETFRAMEWORK
if (game.Comment != null && game.Comment.Any())
machine.Comment = string.Join(";", game.Comment);
if (game.Category != null && game.Category.Any())
machine.Category = string.Join(";", game.Category);
#else
if (game.Comment != null && game.Comment.Any()) if (game.Comment != null && game.Comment.Any())
machine.Comment = string.Join(';', game.Comment); machine.Comment = string.Join(';', game.Comment);
if (game.Category != null && game.Category.Any()) if (game.Category != null && game.Category.Any())
machine.Category = string.Join(';', game.Category); machine.Category = string.Join(';', game.Category);
#endif
if (game.Trurip != null) if (game.Trurip != null)
{ {

View File

@@ -35,70 +35,70 @@ namespace SabreTools.DatFiles.Formats
switch (datItem) switch (datItem)
{ {
case Release release: case Release release:
if (string.IsNullOrWhiteSpace(release.Name)) if (string.IsNullOrEmpty(release.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(release.Region)) if (string.IsNullOrEmpty(release.Region))
missingFields.Add(DatItemField.Region); missingFields.Add(DatItemField.Region);
break; break;
case BiosSet biosset: case BiosSet biosset:
if (string.IsNullOrWhiteSpace(biosset.Name)) if (string.IsNullOrEmpty(biosset.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(biosset.Description)) if (string.IsNullOrEmpty(biosset.Description))
missingFields.Add(DatItemField.Description); missingFields.Add(DatItemField.Description);
break; break;
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.Name)) if (string.IsNullOrEmpty(rom.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC) if (string.IsNullOrEmpty(rom.CRC)
&& string.IsNullOrWhiteSpace(rom.MD5) && string.IsNullOrEmpty(rom.MD5)
&& string.IsNullOrWhiteSpace(rom.SHA1) && string.IsNullOrEmpty(rom.SHA1)
&& string.IsNullOrWhiteSpace(rom.SHA256) && string.IsNullOrEmpty(rom.SHA256)
&& string.IsNullOrWhiteSpace(rom.SHA384) && string.IsNullOrEmpty(rom.SHA384)
&& string.IsNullOrWhiteSpace(rom.SHA512) && string.IsNullOrEmpty(rom.SHA512)
&& string.IsNullOrWhiteSpace(rom.SpamSum)) && string.IsNullOrEmpty(rom.SpamSum))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case Disk disk: case Disk disk:
if (string.IsNullOrWhiteSpace(disk.Name)) if (string.IsNullOrEmpty(disk.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(disk.MD5) if (string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case Media media: case Media media:
if (string.IsNullOrWhiteSpace(media.Name)) if (string.IsNullOrEmpty(media.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(media.MD5) if (string.IsNullOrEmpty(media.MD5)
&& string.IsNullOrWhiteSpace(media.SHA1) && string.IsNullOrEmpty(media.SHA1)
&& string.IsNullOrWhiteSpace(media.SHA256) && string.IsNullOrEmpty(media.SHA256)
&& string.IsNullOrWhiteSpace(media.SpamSum)) && string.IsNullOrEmpty(media.SpamSum))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
break; break;
case DeviceReference deviceref: case DeviceReference deviceref:
if (string.IsNullOrWhiteSpace(deviceref.Name)) if (string.IsNullOrEmpty(deviceref.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Sample sample: case Sample sample:
if (string.IsNullOrWhiteSpace(sample.Name)) if (string.IsNullOrEmpty(sample.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Archive archive: case Archive archive:
if (string.IsNullOrWhiteSpace(archive.Name)) if (string.IsNullOrEmpty(archive.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
@@ -114,9 +114,9 @@ namespace SabreTools.DatFiles.Formats
break; break;
case DatItems.Formats.SoftwareList softwarelist: case DatItems.Formats.SoftwareList softwarelist:
if (string.IsNullOrWhiteSpace(softwarelist.Tag)) if (string.IsNullOrEmpty(softwarelist.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
if (string.IsNullOrWhiteSpace(softwarelist.Name)) if (string.IsNullOrEmpty(softwarelist.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (!softwarelist.StatusSpecified) if (!softwarelist.StatusSpecified)
missingFields.Add(DatItemField.SoftwareListStatus); missingFields.Add(DatItemField.SoftwareListStatus);
@@ -137,7 +137,7 @@ namespace SabreTools.DatFiles.Formats
// Only write the doctype if we don't have No-Intro data // Only write the doctype if we don't have No-Intro data
bool success; bool success;
if (string.IsNullOrWhiteSpace(Header.NoIntroID)) if (string.IsNullOrEmpty(Header.NoIntroID))
success = new Serialization.Files.Logiqx().SerializeToFileWithDocType(datafile, outfile); success = new Serialization.Files.Logiqx().SerializeToFileWithDocType(datafile, outfile);
else else
success = new Serialization.Files.Logiqx().Serialize(datafile, outfile); success = new Serialization.Files.Logiqx().Serialize(datafile, outfile);
@@ -222,7 +222,7 @@ namespace SabreTools.DatFiles.Formats
if (!Header.ForceMergingSpecified if (!Header.ForceMergingSpecified
&& !Header.ForceNodumpSpecified && !Header.ForceNodumpSpecified
&& !Header.ForcePackingSpecified && !Header.ForcePackingSpecified
&& string.IsNullOrWhiteSpace(Header.HeaderSkipper)) && string.IsNullOrEmpty(Header.HeaderSkipper))
{ {
return null; return null;
} }
@@ -248,7 +248,7 @@ namespace SabreTools.DatFiles.Formats
private Models.Logiqx.RomCenter? CreateRomCenter() private Models.Logiqx.RomCenter? CreateRomCenter()
{ {
// If we don't have subheader values, we can't do anything // If we don't have subheader values, we can't do anything
if (string.IsNullOrWhiteSpace(Header.System) if (string.IsNullOrEmpty(Header.System)
&& !Header.RomModeSpecified && !Header.RomModeSpecified
&& !Header.BiosModeSpecified && !Header.BiosModeSpecified
&& !Header.SampleModeSpecified && !Header.SampleModeSpecified
@@ -391,12 +391,21 @@ namespace SabreTools.DatFiles.Formats
game.Name = machine.Name; game.Name = machine.Name;
game.SourceFile = machine.SourceFile; game.SourceFile = machine.SourceFile;
#if NETFRAMEWORK
if ((machine.MachineType & MachineType.Bios) != 0)
game.IsBios = "yes";
if ((machine.MachineType & MachineType.Device) != 0)
game.IsDevice = "yes";
if ((machine.MachineType & MachineType.Mechanical) != 0)
game.IsMechanical = "yes";
#else
if (machine.MachineType.HasFlag(MachineType.Bios)) if (machine.MachineType.HasFlag(MachineType.Bios))
game.IsBios = "yes"; game.IsBios = "yes";
if (machine.MachineType.HasFlag(MachineType.Device)) if (machine.MachineType.HasFlag(MachineType.Device))
game.IsDevice = "yes"; game.IsDevice = "yes";
if (machine.MachineType.HasFlag(MachineType.Mechanical)) if (machine.MachineType.HasFlag(MachineType.Mechanical))
game.IsMechanical = "yes"; game.IsMechanical = "yes";
#endif
game.CloneOf = machine.CloneOf; game.CloneOf = machine.CloneOf;
game.RomOf = machine.RomOf; game.RomOf = machine.RomOf;
game.SampleOf = machine.SampleOf; game.SampleOf = machine.SampleOf;
@@ -434,15 +443,15 @@ namespace SabreTools.DatFiles.Formats
private static Models.Logiqx.Trurip? CreateTrurip(Machine machine) private static Models.Logiqx.Trurip? CreateTrurip(Machine machine)
{ {
// If we don't have subheader values, we can't do anything // If we don't have subheader values, we can't do anything
if (string.IsNullOrWhiteSpace(machine.TitleID) if (string.IsNullOrEmpty(machine.TitleID)
&& string.IsNullOrWhiteSpace(machine.Developer) && string.IsNullOrEmpty(machine.Developer)
&& string.IsNullOrWhiteSpace(machine.Genre) && string.IsNullOrEmpty(machine.Genre)
&& string.IsNullOrWhiteSpace(machine.Subgenre) && string.IsNullOrEmpty(machine.Subgenre)
&& string.IsNullOrWhiteSpace(machine.Ratings) && string.IsNullOrEmpty(machine.Ratings)
&& string.IsNullOrWhiteSpace(machine.Score) && string.IsNullOrEmpty(machine.Score)
&& string.IsNullOrWhiteSpace(machine.Enabled) && string.IsNullOrEmpty(machine.Enabled)
&& !machine.CrcSpecified && !machine.CrcSpecified
&& string.IsNullOrWhiteSpace(machine.RelatedTo)) && string.IsNullOrEmpty(machine.RelatedTo))
{ {
return null; return null;
} }

View File

@@ -364,7 +364,7 @@ namespace SabreTools.DatFiles.Formats
foreach (var crc in files.RomCRC) foreach (var crc in files.RomCRC)
{ {
string name = string.Empty; string name = string.Empty;
if (!string.IsNullOrWhiteSpace(releaseNumber) && releaseNumber != "0") if (!string.IsNullOrEmpty(releaseNumber) && releaseNumber != "0")
name += $"{releaseNumber} - "; name += $"{releaseNumber} - ";
name += $"{machine.Name}{crc.Extension}"; name += $"{machine.Name}{crc.Extension}";

View File

@@ -26,7 +26,7 @@ namespace SabreTools.DatFiles.Formats
{ {
var missingFields = new List<DatItemField>(); var missingFields = new List<DatItemField>();
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
@@ -34,7 +34,7 @@ namespace SabreTools.DatFiles.Formats
case Rom rom: case Rom rom:
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC)) if (string.IsNullOrEmpty(rom.CRC))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }

View File

@@ -140,7 +140,7 @@ namespace SabreTools.DatFiles.Formats
var rom = dump.Rom; var rom = dump.Rom;
string name = $"{machine.Name}_{index++}{(!string.IsNullOrWhiteSpace(rom.Remark) ? $" {rom.Remark}" : string.Empty)}"; string name = $"{machine.Name}_{index++}{(!string.IsNullOrEmpty(rom.Remark) ? $" {rom.Remark}" : string.Empty)}";
var item = new Rom var item = new Rom
{ {
Name = name, Name = name,

View File

@@ -26,13 +26,13 @@ namespace SabreTools.DatFiles.Formats
{ {
var missingFields = new List<DatItemField>(); var missingFields = new List<DatItemField>();
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
{ {
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.SHA1)) if (string.IsNullOrEmpty(rom.SHA1))
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
break; break;
} }

View File

@@ -27,13 +27,13 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
{ {
case Rom rom: case Rom rom:
if (string.IsNullOrWhiteSpace(rom.CRC)) if (string.IsNullOrEmpty(rom.CRC))
missingFields.Add(DatItemField.CRC); missingFields.Add(DatItemField.CRC);
if (!rom.SizeSpecified) if (!rom.SizeSpecified)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);

View File

@@ -457,8 +457,8 @@ namespace SabreTools.DatFiles.Formats
private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem) private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
{ {
// No game should start with a path separator // No game should start with a path separator
if (!string.IsNullOrWhiteSpace(datItem.Machine.Name)) if (!string.IsNullOrEmpty(datItem.Machine.Name))
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty; datItem.Machine.Name = datItem.Machine.Name!.TrimStart(Path.DirectorySeparatorChar);
// Build the state // Build the state
jtw.WriteStartObject(); jtw.WriteStartObject();

View File

@@ -30,7 +30,9 @@ namespace SabreTools.DatFiles.Formats
XmlReader? xtr = XmlReader.Create(filename, new XmlReaderSettings XmlReader? xtr = XmlReader.Create(filename, new XmlReaderSettings
{ {
CheckCharacters = false, CheckCharacters = false,
#if NET40_OR_GREATER
DtdProcessing = DtdProcessing.Ignore, DtdProcessing = DtdProcessing.Ignore,
#endif
IgnoreComments = true, IgnoreComments = true,
IgnoreWhitespace = true, IgnoreWhitespace = true,
ValidationFlags = XmlSchemaValidationFlags.None, ValidationFlags = XmlSchemaValidationFlags.None,
@@ -83,7 +85,9 @@ namespace SabreTools.DatFiles.Formats
xtr?.Read(); xtr?.Read();
} }
#if NET452_OR_GREATER
xtr?.Dispose(); xtr?.Dispose();
#endif
} }
/// <summary> /// <summary>
@@ -246,7 +250,9 @@ namespace SabreTools.DatFiles.Formats
WriteFooter(xtw); WriteFooter(xtw);
logger.User($"'{outfile}' written!{Environment.NewLine}"); logger.User($"'{outfile}' written!{Environment.NewLine}");
#if NET452_OR_GREATER
xtw.Dispose(); xtw.Dispose();
#endif
fs.Dispose(); fs.Dispose();
} }
catch (Exception ex) when (!throwOnError) catch (Exception ex) when (!throwOnError)

View File

@@ -30,14 +30,14 @@ namespace SabreTools.DatFiles.Formats
List<DatItemField> missingFields = []; List<DatItemField> missingFields = [];
// Check item name // Check item name
if (string.IsNullOrWhiteSpace(datItem.GetName())) if (string.IsNullOrEmpty(datItem.GetName()))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
switch (datItem) switch (datItem)
{ {
case Disk disk: case Disk disk:
if (string.IsNullOrWhiteSpace(disk.MD5) if (string.IsNullOrEmpty(disk.MD5)
&& string.IsNullOrWhiteSpace(disk.SHA1)) && string.IsNullOrEmpty(disk.SHA1))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }
@@ -46,13 +46,13 @@ namespace SabreTools.DatFiles.Formats
case Rom rom: case Rom rom:
if (rom.Size == null || rom.Size < 0) if (rom.Size == null || rom.Size < 0)
missingFields.Add(DatItemField.Size); missingFields.Add(DatItemField.Size);
if (string.IsNullOrWhiteSpace(rom.CRC) if (string.IsNullOrEmpty(rom.CRC)
&& string.IsNullOrWhiteSpace(rom.MD5) && string.IsNullOrEmpty(rom.MD5)
&& string.IsNullOrWhiteSpace(rom.SHA1) && string.IsNullOrEmpty(rom.SHA1)
&& string.IsNullOrWhiteSpace(rom.SHA256) && string.IsNullOrEmpty(rom.SHA256)
&& string.IsNullOrWhiteSpace(rom.SHA384) && string.IsNullOrEmpty(rom.SHA384)
&& string.IsNullOrWhiteSpace(rom.SHA512) && string.IsNullOrEmpty(rom.SHA512)
&& string.IsNullOrWhiteSpace(rom.SpamSum)) && string.IsNullOrEmpty(rom.SpamSum))
{ {
missingFields.Add(DatItemField.SHA1); missingFields.Add(DatItemField.SHA1);
} }

View File

@@ -41,22 +41,22 @@ namespace SabreTools.DatFiles.Formats
} }
else else
{ {
if (string.IsNullOrWhiteSpace(dipSwitch.Part!.Name)) if (string.IsNullOrEmpty(dipSwitch.Part!.Name))
missingFields.Add(DatItemField.Part_Name); missingFields.Add(DatItemField.Part_Name);
if (string.IsNullOrWhiteSpace(dipSwitch.Part.Interface)) if (string.IsNullOrEmpty(dipSwitch.Part.Interface))
missingFields.Add(DatItemField.Part_Interface); missingFields.Add(DatItemField.Part_Interface);
} }
if (string.IsNullOrWhiteSpace(dipSwitch.Name)) if (string.IsNullOrEmpty(dipSwitch.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
if (string.IsNullOrWhiteSpace(dipSwitch.Tag)) if (string.IsNullOrEmpty(dipSwitch.Tag))
missingFields.Add(DatItemField.Tag); missingFields.Add(DatItemField.Tag);
if (string.IsNullOrWhiteSpace(dipSwitch.Mask)) if (string.IsNullOrEmpty(dipSwitch.Mask))
missingFields.Add(DatItemField.Mask); missingFields.Add(DatItemField.Mask);
if (dipSwitch.ValuesSpecified) if (dipSwitch.ValuesSpecified)
{ {
if (dipSwitch.Values!.Any(dv => string.IsNullOrWhiteSpace(dv.Name))) if (dipSwitch.Values!.Any(dv => string.IsNullOrEmpty(dv.Name)))
missingFields.Add(DatItemField.Part_Feature_Name); missingFields.Add(DatItemField.Part_Feature_Name);
if (dipSwitch.Values!.Any(dv => string.IsNullOrWhiteSpace(dv.Value))) if (dipSwitch.Values!.Any(dv => string.IsNullOrEmpty(dv.Value)))
missingFields.Add(DatItemField.Part_Feature_Value); missingFields.Add(DatItemField.Part_Feature_Value);
} }
@@ -70,9 +70,9 @@ namespace SabreTools.DatFiles.Formats
} }
else else
{ {
if (string.IsNullOrWhiteSpace(disk.Part!.Name)) if (string.IsNullOrEmpty(disk.Part!.Name))
missingFields.Add(DatItemField.Part_Name); missingFields.Add(DatItemField.Part_Name);
if (string.IsNullOrWhiteSpace(disk.Part.Interface)) if (string.IsNullOrEmpty(disk.Part.Interface))
missingFields.Add(DatItemField.Part_Interface); missingFields.Add(DatItemField.Part_Interface);
} }
if (!disk.DiskAreaSpecified) if (!disk.DiskAreaSpecified)
@@ -81,15 +81,15 @@ namespace SabreTools.DatFiles.Formats
} }
else else
{ {
if (string.IsNullOrWhiteSpace(disk.DiskArea!.Name)) if (string.IsNullOrEmpty(disk.DiskArea!.Name))
missingFields.Add(DatItemField.AreaName); missingFields.Add(DatItemField.AreaName);
} }
if (string.IsNullOrWhiteSpace(disk.Name)) if (string.IsNullOrEmpty(disk.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
case Info info: case Info info:
if (string.IsNullOrWhiteSpace(info.Name)) if (string.IsNullOrEmpty(info.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
@@ -101,9 +101,9 @@ namespace SabreTools.DatFiles.Formats
} }
else else
{ {
if (string.IsNullOrWhiteSpace(rom.Part!.Name)) if (string.IsNullOrEmpty(rom.Part!.Name))
missingFields.Add(DatItemField.Part_Name); missingFields.Add(DatItemField.Part_Name);
if (string.IsNullOrWhiteSpace(rom.Part.Interface)) if (string.IsNullOrEmpty(rom.Part.Interface))
missingFields.Add(DatItemField.Part_Interface); missingFields.Add(DatItemField.Part_Interface);
} }
if (!rom.DataAreaSpecified) if (!rom.DataAreaSpecified)
@@ -113,7 +113,7 @@ namespace SabreTools.DatFiles.Formats
} }
else else
{ {
if (string.IsNullOrWhiteSpace(rom.DataArea!.Name)) if (string.IsNullOrEmpty(rom.DataArea!.Name))
missingFields.Add(DatItemField.AreaName); missingFields.Add(DatItemField.AreaName);
if (!rom.DataArea.SizeSpecified) if (!rom.DataArea.SizeSpecified)
missingFields.Add(DatItemField.AreaSize); missingFields.Add(DatItemField.AreaSize);
@@ -121,7 +121,7 @@ namespace SabreTools.DatFiles.Formats
break; break;
case SharedFeature sharedFeat: case SharedFeature sharedFeat:
if (string.IsNullOrWhiteSpace(sharedFeat.Name)) if (string.IsNullOrEmpty(sharedFeat.Name))
missingFields.Add(DatItemField.Name); missingFields.Add(DatItemField.Name);
break; break;
default: default:

View File

@@ -1,5 +1,7 @@
using System.Collections; using System.Collections;
#if NET40_OR_GREATER || NETCOREAPP
using System.Collections.Concurrent; using System.Collections.Concurrent;
#endif
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -39,7 +41,11 @@ namespace SabreTools.DatFiles
/// <summary> /// <summary>
/// Internal dictionary for the class /// Internal dictionary for the class
/// </summary> /// </summary>
#if NET40_OR_GREATER || NETCOREAPP
private readonly ConcurrentDictionary<string, ConcurrentList<DatItem>?> items; private readonly ConcurrentDictionary<string, ConcurrentList<DatItem>?> items;
#else
private readonly Dictionary<string, ConcurrentList<DatItem>?> items;
#endif
/// <summary> /// <summary>
/// Lock for statistics calculation /// Lock for statistics calculation
@@ -499,8 +505,8 @@ namespace SabreTools.DatFiles
DiskCount++; DiskCount++;
if (disk.ItemStatus != ItemStatus.Nodump) if (disk.ItemStatus != ItemStatus.Nodump)
{ {
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
} }
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -528,10 +534,10 @@ namespace SabreTools.DatFiles
break; break;
case Media media: case Media media:
MediaCount++; MediaCount++;
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1); SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
break; break;
case Part: case Part:
PartCount++; PartCount++;
@@ -556,13 +562,13 @@ namespace SabreTools.DatFiles
if (rom.ItemStatus != ItemStatus.Nodump) if (rom.ItemStatus != ItemStatus.Nodump)
{ {
TotalSize += rom.Size ?? 0; TotalSize += rom.Size ?? 0;
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1); CRCCount += (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1); SHA384Count += (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1); SHA512Count += (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1); SpamSumCount += (string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
} }
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -709,7 +715,11 @@ namespace SabreTools.DatFiles
{ {
// If the key is missing from the dictionary, add it // If the key is missing from the dictionary, add it
if (!items.ContainsKey(key)) if (!items.ContainsKey(key))
#if NET40_OR_GREATER || NETCOREAPP
items.TryAdd(key, []); items.TryAdd(key, []);
#else
items[key] = [];
#endif
} }
/// <summary> /// <summary>
@@ -753,7 +763,11 @@ namespace SabreTools.DatFiles
} }
// Remove the key from the dictionary // Remove the key from the dictionary
#if NET40_OR_GREATER || NETCOREAPP
return items.TryRemove(key, out _); return items.TryRemove(key, out _);
#else
return items.Remove(key);
#endif
} }
} }
@@ -867,8 +881,8 @@ namespace SabreTools.DatFiles
DiskCount--; DiskCount--;
if (disk.ItemStatus != ItemStatus.Nodump) if (disk.ItemStatus != ItemStatus.Nodump)
{ {
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
} }
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -896,9 +910,9 @@ namespace SabreTools.DatFiles
break; break;
case Media media: case Media media:
MediaCount--; MediaCount--;
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
break; break;
case Part: case Part:
PartCount--; PartCount--;
@@ -920,12 +934,12 @@ namespace SabreTools.DatFiles
if (rom.ItemStatus != ItemStatus.Nodump) if (rom.ItemStatus != ItemStatus.Nodump)
{ {
TotalSize -= rom.Size ?? 0; TotalSize -= rom.Size ?? 0;
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1); CRCCount -= (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1); SHA384Count -= (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1); SHA512Count -= (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
} }
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -963,7 +977,11 @@ namespace SabreTools.DatFiles
{ {
bucketedBy = ItemKey.NULL; bucketedBy = ItemKey.NULL;
mergedBy = DedupeType.None; mergedBy = DedupeType.None;
#if NET40_OR_GREATER || NETCOREAPP
items = new ConcurrentDictionary<string, ConcurrentList<DatItem>?>(); items = new ConcurrentDictionary<string, ConcurrentList<DatItem>?>();
#else
items = new Dictionary<string, ConcurrentList<DatItem>?>();
#endif
logger = new Logger(this); logger = new Logger(this);
} }
@@ -981,7 +999,11 @@ namespace SabreTools.DatFiles
public void BucketBy(ItemKey bucketBy, DedupeType dedupeType, bool lower = true, bool norename = true) public void BucketBy(ItemKey bucketBy, DedupeType dedupeType, bool lower = true, bool norename = true)
{ {
// If we have a situation where there's no dictionary or no keys at all, we skip // If we have a situation where there's no dictionary or no keys at all, we skip
#if NET40_OR_GREATER || NETCOREAPP
if (items == null || items.IsEmpty) if (items == null || items.IsEmpty)
#else
if (items == null || items.Count == 0)
#endif
return; return;
// If the sorted type isn't the same, we want to sort the dictionary accordingly // If the sorted type isn't the same, we want to sort the dictionary accordingly
@@ -997,7 +1019,14 @@ namespace SabreTools.DatFiles
// First do the initial sort of all of the roms inplace // First do the initial sort of all of the roms inplace
List<string> oldkeys = [.. Keys]; List<string> oldkeys = [.. Keys];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k => Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k =>
#elif NET40_OR_GREATER
Parallel.For(0, oldkeys.Count, k =>
#else
for (int k = 0; k < oldkeys.Count; k++)
#endif
{ {
string key = oldkeys[k]; string key = oldkeys[k];
if (this[key] == null) if (this[key] == null)
@@ -1025,7 +1054,11 @@ namespace SabreTools.DatFiles
// If the key is now empty, remove it // If the key is now empty, remove it
if (this[key]!.Count == 0) if (this[key]!.Count == 0)
Remove(key); Remove(key);
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
} }
// If the merge type isn't the same, we want to merge the dictionary accordingly // If the merge type isn't the same, we want to merge the dictionary accordingly
@@ -1037,7 +1070,13 @@ namespace SabreTools.DatFiles
mergedBy = dedupeType; mergedBy = dedupeType;
List<string> keys = [.. Keys]; List<string> keys = [.. Keys];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Get the possibly unsorted list // Get the possibly unsorted list
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList(); ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
@@ -1064,7 +1103,13 @@ namespace SabreTools.DatFiles
else else
{ {
List<string> keys = [.. Keys]; List<string> keys = [.. Keys];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Get the possibly unsorted list // Get the possibly unsorted list
ConcurrentList<DatItem>? sortedlist = this[key]; ConcurrentList<DatItem>? sortedlist = this[key];
@@ -1094,11 +1139,19 @@ namespace SabreTools.DatFiles
// If the value is null, remove // If the value is null, remove
else if (items[key] == null) else if (items[key] == null)
#if NET40_OR_GREATER || NETCOREAPP
items.TryRemove(key, out _); items.TryRemove(key, out _);
#else
items.Remove(key);
#endif
// If there are no non-blank items, remove // If there are no non-blank items, remove
else if (!items[key]!.Any(i => i != null && i.ItemType != ItemType.Blank)) else if (!items[key]!.Any(i => i != null && i.ItemType != ItemType.Blank))
#if NET40_OR_GREATER || NETCOREAPP
items.TryRemove(key, out _); items.TryRemove(key, out _);
#else
items.Remove(key);
#endif
} }
} }

View File

@@ -1,4 +1,6 @@
using System; #if NET462_OR_GREATER || NETCOREAPP
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -63,11 +65,11 @@ namespace SabreTools.DatFiles
/// <summary> /// <summary>
/// Item dictionary file name /// Item dictionary file name
/// </summary> /// </summary>
public string ItemDictionaryFileName public string? ItemDictionaryFileName
{ {
get get
{ {
if (string.IsNullOrWhiteSpace(itemDictionaryFileName)) if (string.IsNullOrEmpty(itemDictionaryFileName))
itemDictionaryFileName = Path.Combine(PathTool.GetRuntimeDirectory(), $"itemDictionary{Guid.NewGuid()}.sqlite"); itemDictionaryFileName = Path.Combine(PathTool.GetRuntimeDirectory(), $"itemDictionary{Guid.NewGuid()}.sqlite");
return itemDictionaryFileName; return itemDictionaryFileName;
@@ -622,8 +624,8 @@ namespace SabreTools.DatFiles
DiskCount++; DiskCount++;
if (disk.ItemStatus != ItemStatus.Nodump) if (disk.ItemStatus != ItemStatus.Nodump)
{ {
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
} }
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -651,10 +653,10 @@ namespace SabreTools.DatFiles
break; break;
case Media media: case Media media:
MediaCount++; MediaCount++;
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1); SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
break; break;
case Part: case Part:
PartCount++; PartCount++;
@@ -679,13 +681,13 @@ namespace SabreTools.DatFiles
if (rom.ItemStatus != ItemStatus.Nodump) if (rom.ItemStatus != ItemStatus.Nodump)
{ {
TotalSize += rom.Size ?? 0; TotalSize += rom.Size ?? 0;
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1); CRCCount += (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1); MD5Count += (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1); SHA1Count += (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1); SHA256Count += (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1); SHA384Count += (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1); SHA512Count += (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1); SpamSumCount += (string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
} }
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -1025,8 +1027,8 @@ namespace SabreTools.DatFiles
DiskCount--; DiskCount--;
if (disk.ItemStatus != ItemStatus.Nodump) if (disk.ItemStatus != ItemStatus.Nodump)
{ {
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
} }
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -1054,9 +1056,9 @@ namespace SabreTools.DatFiles
break; break;
case Media media: case Media media:
MediaCount--; MediaCount--;
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
break; break;
case Part: case Part:
PartCount--; PartCount--;
@@ -1078,12 +1080,12 @@ namespace SabreTools.DatFiles
if (rom.ItemStatus != ItemStatus.Nodump) if (rom.ItemStatus != ItemStatus.Nodump)
{ {
TotalSize -= rom.Size ?? 0; TotalSize -= rom.Size ?? 0;
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1); CRCCount -= (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1); MD5Count -= (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1); SHA1Count -= (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1); SHA256Count -= (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1); SHA384Count -= (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1); SHA512Count -= (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
} }
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0); BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
@@ -1135,7 +1137,7 @@ namespace SabreTools.DatFiles
protected void EnsureDatabase() protected void EnsureDatabase()
{ {
// Make sure the file exists // Make sure the file exists
if (!System.IO.File.Exists(ItemDictionaryFileName)) if (ItemDictionaryFileName != null && !System.IO.File.Exists(ItemDictionaryFileName))
System.IO.File.Create(ItemDictionaryFileName); System.IO.File.Create(ItemDictionaryFileName);
// If we have no database connection, we can't do anything // If we have no database connection, we can't do anything
@@ -1197,7 +1199,13 @@ CREATE TABLE IF NOT EXISTS groups (
// First do the initial sort of all of the roms inplace // First do the initial sort of all of the roms inplace
List<string> oldkeys = Keys.ToList(); List<string> oldkeys = Keys.ToList();
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k => Parallel.For(0, oldkeys.Count, Globals.ParallelOptions, k =>
#elif NET40_OR_GREATER
Parallel.For(0, oldkeys.Count, k =>
#else
for (int k = 0; k < oldkeys.Count; k++)
#endif
{ {
string key = oldkeys[k]; string key = oldkeys[k];
if (this[key] == null) if (this[key] == null)
@@ -1225,7 +1233,11 @@ CREATE TABLE IF NOT EXISTS groups (
// If the key is now empty, remove it // If the key is now empty, remove it
if (this[key]!.Count == 0) if (this[key]!.Count == 0)
Remove(key); Remove(key);
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
} }
// If the merge type isn't the same, we want to merge the dictionary accordingly // If the merge type isn't the same, we want to merge the dictionary accordingly
@@ -1237,7 +1249,13 @@ CREATE TABLE IF NOT EXISTS groups (
mergedBy = dedupeType; mergedBy = dedupeType;
List<string> keys = Keys.ToList(); List<string> keys = Keys.ToList();
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Get the possibly unsorted list // Get the possibly unsorted list
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList(); ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
@@ -1264,7 +1282,13 @@ CREATE TABLE IF NOT EXISTS groups (
else else
{ {
List<string> keys = Keys.ToList(); List<string> keys = Keys.ToList();
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Get the possibly unsorted list // Get the possibly unsorted list
ConcurrentList<DatItem>? sortedlist = this[key]; ConcurrentList<DatItem>? sortedlist = this[key];
@@ -1530,3 +1554,5 @@ CREATE TABLE IF NOT EXISTS groups (
#endregion #endregion
} }
} }
#endif

View File

@@ -1,10 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> <!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.1.2</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2016-2024 Matt Nadareski</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<RepositoryUrl>https://github.com/SabreTools/SabreTools</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -14,8 +27,12 @@
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" /> <ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <!-- Support for old .NET versions -->
<ItemGroup Condition="!$(TargetFramework.StartsWith(`net2`)) AND !$(TargetFramework.StartsWith(`net3`)) AND !$(TargetFramework.StartsWith(`net40`)) AND !$(TargetFramework.StartsWith(`net452`))">
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" /> <PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SabreTools.IO" Version="1.3.0" /> <PackageReference Include="SabreTools.IO" Version="1.3.0" />
<PackageReference Include="SabreTools.Models" Version="1.3.0" /> <PackageReference Include="SabreTools.Models" Version="1.3.0" />

View File

@@ -33,7 +33,13 @@ namespace SabreTools.DatTools
public static void ApplySuperDAT(DatFile datFile, List<ParentablePath> inputs) public static void ApplySuperDAT(DatFile datFile, List<ParentablePath> inputs)
{ {
List<string> keys = [.. datFile.Items.Keys]; List<string> keys = [.. datFile.Items.Keys];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
ConcurrentList<DatItem>? items = datFile.Items[key]; ConcurrentList<DatItem>? items = datFile.Items[key];
if (items == null) if (items == null)
@@ -98,7 +104,13 @@ namespace SabreTools.DatTools
intDat.Items.BucketBy(ItemKey.CRC, DedupeType.None); intDat.Items.BucketBy(ItemKey.CRC, DedupeType.None);
// Then we do a hashwise comparison against the base DAT // Then we do a hashwise comparison against the base DAT
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(intDat.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(intDat.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(intDat.Items.Keys, key =>
#else
foreach (var key in intDat.Items.Keys)
#endif
{ {
ConcurrentList<DatItem>? datItems = intDat.Items[key]; ConcurrentList<DatItem>? datItems = intDat.Items[key];
if (datItems == null) if (datItems == null)
@@ -136,7 +148,13 @@ namespace SabreTools.DatTools
intDat.Items.BucketBy(ItemKey.Machine, DedupeType.None); intDat.Items.BucketBy(ItemKey.Machine, DedupeType.None);
// Then we do a namewise comparison against the base DAT // Then we do a namewise comparison against the base DAT
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(intDat.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(intDat.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(intDat.Items.Keys, key =>
#else
foreach (var key in intDat.Items.Keys)
#endif
{ {
ConcurrentList<DatItem>? datItems = intDat.Items[key]; ConcurrentList<DatItem>? datItems = intDat.Items[key];
if (datItems == null) if (datItems == null)
@@ -194,7 +212,13 @@ namespace SabreTools.DatTools
// Then we compare against the base DAT // Then we compare against the base DAT
List<string> keys = [.. intDat.Items.Keys]; List<string> keys = [.. intDat.Items.Keys];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Game Against uses game names // Game Against uses game names
if (useGames) if (useGames)
@@ -274,13 +298,23 @@ namespace SabreTools.DatTools
// Create the DatFiles from the set of headers // Create the DatFiles from the set of headers
DatFile[] outDatsArray = new DatFile[datHeaders.Count]; DatFile[] outDatsArray = new DatFile[datHeaders.Count];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, datHeaders.Count, Globals.ParallelOptions, j => Parallel.For(0, datHeaders.Count, Globals.ParallelOptions, j =>
#elif NET40_OR_GREATER
Parallel.For(0, datHeaders.Count, j =>
#else
for (int j = 0; j < datHeaders.Count; j++)
#endif
{ {
DatFile diffData = DatFile.Create(datHeaders[j]); DatFile diffData = DatFile.Create(datHeaders[j]);
diffData.Items = []; diffData.Items = [];
FillWithSourceIndex(datFile, diffData, j); FillWithSourceIndex(datFile, diffData, j);
outDatsArray[j] = diffData; outDatsArray[j] = diffData;
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
outDats = [.. outDatsArray]; outDats = [.. outDatsArray];
watch.Stop(); watch.Stop();
@@ -330,7 +364,13 @@ namespace SabreTools.DatTools
// Now, loop through the dictionary and populate the correct DATs // Now, loop through the dictionary and populate the correct DATs
watch.Start("Populating duplicate DAT"); watch.Start("Populating duplicate DAT");
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]); ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]);
@@ -341,7 +381,11 @@ namespace SabreTools.DatTools
// Loop through and add the items correctly // Loop through and add the items correctly
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
#if NETFRAMEWORK
if ((item.DupeType & DupeType.External) != 0)
#else
if (item.DupeType.HasFlag(DupeType.External)) if (item.DupeType.HasFlag(DupeType.External))
#endif
{ {
if (item.Clone() is not DatItem newrom) if (item.Clone() is not DatItem newrom)
continue; continue;
@@ -396,7 +440,13 @@ namespace SabreTools.DatTools
// Loop through each of the inputs and get or create a new DatData object // Loop through each of the inputs and get or create a new DatData object
DatFile[] outDatsArray = new DatFile[inputs.Count]; DatFile[] outDatsArray = new DatFile[inputs.Count];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, inputs.Count, Globals.ParallelOptions, j => Parallel.For(0, inputs.Count, Globals.ParallelOptions, j =>
#elif NET40_OR_GREATER
Parallel.For(0, inputs.Count, j =>
#else
for (int j = 0; j < inputs.Count; j++)
#endif
{ {
string innerpost = $" ({j} - {inputs[j].GetNormalizedFileName(true)} Only)"; string innerpost = $" ({j} - {inputs[j].GetNormalizedFileName(true)} Only)";
DatFile diffData = DatFile.Create(datFile.Header); DatFile diffData = DatFile.Create(datFile.Header);
@@ -405,7 +455,11 @@ namespace SabreTools.DatTools
diffData.Header.Description += innerpost; diffData.Header.Description += innerpost;
diffData.Items = []; diffData.Items = [];
outDatsArray[j] = diffData; outDatsArray[j] = diffData;
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
// Create a list of DatData objects representing individual output files // Create a list of DatData objects representing individual output files
List<DatFile> outDats = [.. outDatsArray]; List<DatFile> outDats = [.. outDatsArray];
@@ -415,7 +469,13 @@ namespace SabreTools.DatTools
// Now, loop through the dictionary and populate the correct DATs // Now, loop through the dictionary and populate the correct DATs
watch.Start("Populating all individual DATs"); watch.Start("Populating all individual DATs");
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]); ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]);
@@ -429,7 +489,11 @@ namespace SabreTools.DatTools
if (item.Source == null) if (item.Source == null)
continue; continue;
#if NETFRAMEWORK
if ((item.DupeType & DupeType.Internal) != 0 || item.DupeType == 0x00)
#else
if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00) if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00)
#endif
outDats[item.Source.Index].Items.Add(key, item); outDats[item.Source.Index].Items.Add(key, item);
} }
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -485,7 +549,13 @@ namespace SabreTools.DatTools
// Now, loop through the dictionary and populate the correct DATs // Now, loop through the dictionary and populate the correct DATs
watch.Start("Populating no duplicate DAT"); watch.Start("Populating no duplicate DAT");
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]); ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]);
@@ -496,7 +566,11 @@ namespace SabreTools.DatTools
// Loop through and add the items correctly // Loop through and add the items correctly
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
#if NETFRAMEWORK
if ((item.DupeType & DupeType.Internal) != 0 || item.DupeType == 0x00)
#else
if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00) if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00)
#endif
{ {
if (item.Clone() is not DatItem newrom || newrom.Source == null) if (item.Clone() is not DatItem newrom || newrom.Source == null)
continue; continue;
@@ -540,13 +614,23 @@ namespace SabreTools.DatTools
InternalStopwatch watch = new("Processing individual DATs"); InternalStopwatch watch = new("Processing individual DATs");
// Parse all of the DATs into their own DatFiles in the array // Parse all of the DATs into their own DatFiles in the array
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, inputs.Count, Globals.ParallelOptions, i => Parallel.For(0, inputs.Count, Globals.ParallelOptions, i =>
#elif NET40_OR_GREATER
Parallel.For(0, inputs.Count, i =>
#else
for (int i = 0; i < inputs.Count; i++)
#endif
{ {
var input = inputs[i]; var input = inputs[i];
logger.User($"Adding DAT: {input.CurrentPath}"); logger.User($"Adding DAT: {input.CurrentPath}");
datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering()); datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering());
Parser.ParseInto(datFiles[i], input, i, keep: true); Parser.ParseInto(datFiles[i], input, i, keep: true);
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
watch.Stop(); watch.Stop();
@@ -596,7 +680,13 @@ namespace SabreTools.DatTools
private static void FillWithSourceIndex(DatFile datFile, DatFile indexDat, int index) private static void FillWithSourceIndex(DatFile datFile, DatFile indexDat, int index)
{ {
// Loop through and add the items for this index to the output // Loop through and add the items for this index to the output
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]); ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]);

View File

@@ -61,7 +61,13 @@ namespace SabreTools.DatTools
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.AllDirectories).ToList(); List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.AllDirectories).ToList();
// Loop through and add the file sizes // Loop through and add the file sizes
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(files, Globals.ParallelOptions, item => Parallel.ForEach(files, Globals.ParallelOptions, item =>
#elif NET40_OR_GREATER
Parallel.ForEach(files, item =>
#else
foreach (var item in files)
#endif
{ {
Interlocked.Add(ref totalSize, new FileInfo(item).Length); Interlocked.Add(ref totalSize, new FileInfo(item).Length);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -132,7 +138,11 @@ namespace SabreTools.DatTools
archive.AvailableHashes = hashes; archive.AvailableHashes = hashes;
// Skip if we're treating archives as files and skipping files // Skip if we're treating archives as files and skipping files
#if NETFRAMEWORK
if ((asFiles & TreatAsFile.Archive) != 0 && skipFileType == SkipFileType.File)
#else
if (asFiles.HasFlag(TreatAsFile.Archive) && skipFileType == SkipFileType.File) if (asFiles.HasFlag(TreatAsFile.Archive) && skipFileType == SkipFileType.File)
#endif
{ {
return; return;
} }
@@ -144,7 +154,11 @@ namespace SabreTools.DatTools
} }
// Process as archive if we're not treating archives as files // Process as archive if we're not treating archives as files
#if NETFRAMEWORK
else if ((!asFiles & TreatAsFile.Archive) != 0)
#else
else if (!asFiles.HasFlag(TreatAsFile.Archive)) else if (!asFiles.HasFlag(TreatAsFile.Archive))
#endif
{ {
var extracted = archive.GetChildren(); var extracted = archive.GetChildren();
@@ -223,7 +237,13 @@ namespace SabreTools.DatTools
string parent = (Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, basePath?.Length ?? 0) + Path.GetFileNameWithoutExtension(item); string parent = (Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, basePath?.Length ?? 0) + Path.GetFileNameWithoutExtension(item);
// First take care of the found items // First take care of the found items
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(extracted, Globals.ParallelOptions, baseFile => Parallel.ForEach(extracted, Globals.ParallelOptions, baseFile =>
#elif NET40_OR_GREATER
Parallel.ForEach(extracted, baseFile =>
#else
foreach (var baseFile in extracted)
#endif
{ {
DatItem? datItem = DatItem.Create(baseFile); DatItem? datItem = DatItem.Create(baseFile);
if (datItem == null) if (datItem == null)
@@ -256,7 +276,13 @@ namespace SabreTools.DatTools
empties = archive.GetEmptyFolders(); empties = archive.GetEmptyFolders();
// Add add all of the found empties to the DAT // Add add all of the found empties to the DAT
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(empties, Globals.ParallelOptions, empty => Parallel.ForEach(empties, Globals.ParallelOptions, empty =>
#elif NET40_OR_GREATER
Parallel.ForEach(empties, empty =>
#else
foreach (var empty in empties)
#endif
{ {
Rom emptyRom = new(Path.Combine(empty, "_"), item); Rom emptyRom = new(Path.Combine(empty, "_"), item);
ProcessFileHelper(datFile, item, emptyRom, basePath, parent); ProcessFileHelper(datFile, item, emptyRom, basePath, parent);
@@ -279,7 +305,13 @@ namespace SabreTools.DatTools
return; return;
List<string> empties = basePath.ListEmpty() ?? []; List<string> empties = basePath.ListEmpty() ?? [];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(empties, Globals.ParallelOptions, dir => Parallel.ForEach(empties, Globals.ParallelOptions, dir =>
#elif NET40_OR_GREATER
Parallel.ForEach(empties, dir =>
#else
foreach (var dir in empties)
#endif
{ {
// Get the full path for the directory // Get the full path for the directory
string fulldir = Path.GetFullPath(dir); string fulldir = Path.GetFullPath(dir);

View File

@@ -76,7 +76,13 @@ namespace SabreTools.DatTools
// Now loop through and get only directories from the input paths // Now loop through and get only directories from the input paths
List<string> directories = []; List<string> directories = [];
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(inputs, Globals.ParallelOptions, input => Parallel.ForEach(inputs, Globals.ParallelOptions, input =>
#elif NET40_OR_GREATER
Parallel.ForEach(inputs, input =>
#else
foreach (var input in inputs)
#endif
{ {
// Add to the list if the input is a directory // Add to the list if the input is a directory
if (Directory.Exists(input)) if (Directory.Exists(input))
@@ -316,9 +322,17 @@ namespace SabreTools.DatTools
DatItem? internalDatItem; DatItem? internalDatItem;
if (internalFileInfo == null) if (internalFileInfo == null)
internalDatItem = null; internalDatItem = null;
#if NETFRAMEWORK
else if (internalFileInfo.Type == FileType.AaruFormat && (asFiles & TreatAsFile.AaruFormat) == 0)
#else
else if (internalFileInfo.Type == FileType.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat)) else if (internalFileInfo.Type == FileType.AaruFormat && !asFiles.HasFlag(TreatAsFile.AaruFormat))
#endif
internalDatItem = new Media(internalFileInfo); internalDatItem = new Media(internalFileInfo);
#if NETFRAMEWORK
else if (internalFileInfo.Type == FileType.CHD && (asFiles & TreatAsFile.CHD) == 0)
#else
else if (internalFileInfo.Type == FileType.CHD && !asFiles.HasFlag(TreatAsFile.CHD)) else if (internalFileInfo.Type == FileType.CHD && !asFiles.HasFlag(TreatAsFile.CHD))
#endif
internalDatItem = new Disk(internalFileInfo); internalDatItem = new Disk(internalFileInfo);
else else
internalDatItem = new Rom(internalFileInfo); internalDatItem = new Rom(internalFileInfo);

View File

@@ -63,7 +63,13 @@ namespace SabreTools.DatTools
extBDat.Header.Description += $" ({newExtBString})"; extBDat.Header.Description += $" ({newExtBString})";
// Now separate the roms accordingly // Now separate the roms accordingly
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem>? items = datFile.Items[key]; ConcurrentList<DatItem>? items = datFile.Items[key];
if (items == null) if (items == null)
@@ -151,7 +157,13 @@ namespace SabreTools.DatTools
fieldDats[DatItemField.NULL].Header.Description += " (Other)"; fieldDats[DatItemField.NULL].Header.Description += " (Other)";
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem>? items = datFile.Items[key]; ConcurrentList<DatItem>? items = datFile.Items[key];
if (items == null) if (items == null)
@@ -250,7 +262,13 @@ namespace SabreTools.DatTools
keys.Sort(SplitByLevelSort); keys.Sort(SplitByLevelSort);
// Then, we loop over the games // Then, we loop over the games
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(keys, Globals.ParallelOptions, key => Parallel.ForEach(keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(keys, key =>
#else
foreach (var key in keys)
#endif
{ {
// Here, the key is the name of the game to be used for comparison // Here, the key is the name of the game to be used for comparison
if (tempDat.Header.Name != null && tempDat.Header.Name != Path.GetDirectoryName(key)) if (tempDat.Header.Name != null && tempDat.Header.Name != Path.GetDirectoryName(key))
@@ -354,7 +372,13 @@ namespace SabreTools.DatTools
greaterThan.Header.Description += $" (equal-greater than {radix})"; greaterThan.Header.Description += $" (equal-greater than {radix})";
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem>? items = datFile.Items[key]; ConcurrentList<DatItem>? items = datFile.Items[key];
if (items == null) if (items == null)
@@ -510,7 +534,13 @@ namespace SabreTools.DatTools
} }
// Now populate each of the DAT objects in turn // Now populate each of the DAT objects in turn
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(outputTypes, Globals.ParallelOptions, itemType => Parallel.ForEach(outputTypes, Globals.ParallelOptions, itemType =>
#elif NET40_OR_GREATER
Parallel.ForEach(outputTypes, itemType =>
#else
foreach (var itemType in outputTypes)
#endif
{ {
FillWithItemType(datFile, typeDats[itemType], itemType); FillWithItemType(datFile, typeDats[itemType], itemType);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -533,7 +563,13 @@ namespace SabreTools.DatTools
private static void FillWithItemType(DatFile datFile, DatFile indexDat, ItemType itemType) private static void FillWithItemType(DatFile datFile, DatFile indexDat, ItemType itemType)
{ {
// Loop through and add the items for this index to the output // Loop through and add the items for this index to the output
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key => Parallel.ForEach(datFile.Items.Keys, Globals.ParallelOptions, key =>
#elif NET40_OR_GREATER
Parallel.ForEach(datFile.Items.Keys, key =>
#else
foreach (var key in datFile.Items.Keys)
#endif
{ {
ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]); ConcurrentList<DatItem> items = DatItem.Merge(datFile.Items[key]);

View File

@@ -171,7 +171,13 @@ namespace SabreTools.DatTools
try try
{ {
// Write out all required formats // Write out all required formats
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(outfiles.Keys, Globals.ParallelOptions, reportFormat => Parallel.ForEach(outfiles.Keys, Globals.ParallelOptions, reportFormat =>
#elif NET40_OR_GREATER
Parallel.ForEach(outfiles.Keys, reportFormat =>
#else
foreach (var reportFormat in outfiles.Keys)
#endif
{ {
string outfile = outfiles[reportFormat]; string outfile = outfiles[reportFormat];
try try
@@ -223,19 +229,39 @@ namespace SabreTools.DatTools
// For each output format, get the appropriate stream writer // For each output format, get the appropriate stream writer
output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite)); output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite));
#if NETFRAMEWORK
if ((statDatFormat & StatReportFormat.Textfile) != 0)
#else
if (statDatFormat.HasFlag(StatReportFormat.Textfile)) if (statDatFormat.HasFlag(StatReportFormat.Textfile))
#endif
output.Add(StatReportFormat.Textfile, CreateOutStatsNamesHelper(outDir, ".txt", reportName, overwrite)); output.Add(StatReportFormat.Textfile, CreateOutStatsNamesHelper(outDir, ".txt", reportName, overwrite));
#if NETFRAMEWORK
if ((statDatFormat & StatReportFormat.CSV) != 0)
#else
if (statDatFormat.HasFlag(StatReportFormat.CSV)) if (statDatFormat.HasFlag(StatReportFormat.CSV))
#endif
output.Add(StatReportFormat.CSV, CreateOutStatsNamesHelper(outDir, ".csv", reportName, overwrite)); output.Add(StatReportFormat.CSV, CreateOutStatsNamesHelper(outDir, ".csv", reportName, overwrite));
#if NETFRAMEWORK
if ((statDatFormat & StatReportFormat.HTML) != 0)
#else
if (statDatFormat.HasFlag(StatReportFormat.HTML)) if (statDatFormat.HasFlag(StatReportFormat.HTML))
#endif
output.Add(StatReportFormat.HTML, CreateOutStatsNamesHelper(outDir, ".html", reportName, overwrite)); output.Add(StatReportFormat.HTML, CreateOutStatsNamesHelper(outDir, ".html", reportName, overwrite));
#if NETFRAMEWORK
if ((statDatFormat & StatReportFormat.SSV) != 0)
#else
if (statDatFormat.HasFlag(StatReportFormat.SSV)) if (statDatFormat.HasFlag(StatReportFormat.SSV))
#endif
output.Add(StatReportFormat.SSV, CreateOutStatsNamesHelper(outDir, ".ssv", reportName, overwrite)); output.Add(StatReportFormat.SSV, CreateOutStatsNamesHelper(outDir, ".ssv", reportName, overwrite));
#if NETFRAMEWORK
if ((statDatFormat & StatReportFormat.TSV) != 0)
#else
if (statDatFormat.HasFlag(StatReportFormat.TSV)) if (statDatFormat.HasFlag(StatReportFormat.TSV))
#endif
output.Add(StatReportFormat.TSV, CreateOutStatsNamesHelper(outDir, ".tsv", reportName, overwrite)); output.Add(StatReportFormat.TSV, CreateOutStatsNamesHelper(outDir, ".tsv", reportName, overwrite));
return output; return output;

View File

@@ -78,8 +78,13 @@ namespace SabreTools.DatTools
try try
{ {
// Write out all required formats // Write out all required formats
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(outfiles.Keys, Globals.ParallelOptions, datFormat => Parallel.ForEach(outfiles.Keys, Globals.ParallelOptions, datFormat =>
#elif NET40_OR_GREATER
Parallel.ForEach(outfiles.Keys, datFormat =>
#else
foreach (var datFormat in outfiles.Keys)
#endif
{ {
string outfile = outfiles[datFormat]; string outfile = outfiles[datFormat];
try try

View File

@@ -117,7 +117,11 @@ namespace SabreTools.Filtering
return null; return null;
// If we have a flag // If we have a flag
#if NETFRAMEWORK
if (typeof(T).IsEnum && ((single as Enum)! & (value as Enum)!) != 0)
#else
if (typeof(T).IsEnum && (single as Enum)!.HasFlag((value as Enum)!)) if (typeof(T).IsEnum && (single as Enum)!.HasFlag((value as Enum)!))
#endif
return true; return true;
return single.Equals(value); return single.Equals(value);

View File

@@ -290,7 +290,11 @@ namespace SabreTools.Filtering
continue; continue;
// If the machine (is/is not) a device, we want to continue // If the machine (is/is not) a device, we want to continue
#if NETFRAMEWORK
if (dev ^ ((datFile.Items[machine]![0].Machine.MachineType & MachineType.Device) != 0))
#else
if (dev ^ (datFile.Items[machine]![0].Machine.MachineType.HasFlag(MachineType.Device))) if (dev ^ (datFile.Items[machine]![0].Machine.MachineType.HasFlag(MachineType.Device)))
#endif
continue; continue;
// Get all device reference names from the current machine // Get all device reference names from the current machine
@@ -589,8 +593,13 @@ namespace SabreTools.Filtering
continue; continue;
if (items.Count > 0 if (items.Count > 0
#if NETFRAMEWORK
&& ((items[0].Machine.MachineType & MachineType.Bios) != 0
|| (items[0].Machine.MachineType & MachineType.Device) != 0))
#else
&& (items[0].Machine.MachineType.HasFlag(MachineType.Bios) && (items[0].Machine.MachineType.HasFlag(MachineType.Bios)
|| items[0].Machine.MachineType.HasFlag(MachineType.Device))) || items[0].Machine.MachineType.HasFlag(MachineType.Device)))
#endif
{ {
datFile.Items.Remove(game); datFile.Items.Remove(game);
} }
@@ -614,7 +623,11 @@ namespace SabreTools.Filtering
continue; continue;
// If the game (is/is not) a bios, we want to continue // If the game (is/is not) a bios, we want to continue
#if NETFRAMEWORK
if (bios ^ (items[0].Machine.MachineType & MachineType.Bios) != 0)
#else
if (bios ^ items[0].Machine.MachineType.HasFlag(MachineType.Bios)) if (bios ^ items[0].Machine.MachineType.HasFlag(MachineType.Bios))
#endif
continue; continue;
// Determine if the game has a parent or not // Determine if the game has a parent or not

View File

@@ -94,7 +94,13 @@ namespace SabreTools.Features
InternalStopwatch watch = new("Outputting hash-split DATs"); InternalStopwatch watch = new("Outputting hash-split DATs");
// Loop through each type DatFile // Loop through each type DatFile
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType => Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
#elif NET40_OR_GREATER
Parallel.ForEach(typeDats.Keys, itemType =>
#else
foreach (var itemType in typeDats.Keys)
#endif
{ {
Writer.Write(typeDats[itemType], OutputDir); Writer.Write(typeDats[itemType], OutputDir);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -140,7 +146,13 @@ namespace SabreTools.Features
InternalStopwatch watch = new("Outputting total-size-split DATs"); InternalStopwatch watch = new("Outputting total-size-split DATs");
// Loop through each type DatFile // Loop through each type DatFile
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(sizedDats, Globals.ParallelOptions, sizedDat => Parallel.ForEach(sizedDats, Globals.ParallelOptions, sizedDat =>
#elif NET40_OR_GREATER
Parallel.ForEach(sizedDats, sizedDat =>
#else
foreach (var sizedDat in sizedDats)
#endif
{ {
Writer.Write(sizedDat, OutputDir); Writer.Write(sizedDat, OutputDir);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP
@@ -160,7 +172,13 @@ namespace SabreTools.Features
InternalStopwatch watch = new("Outputting ItemType DATs"); InternalStopwatch watch = new("Outputting ItemType DATs");
// Loop through each type DatFile // Loop through each type DatFile
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType => Parallel.ForEach(typeDats.Keys, Globals.ParallelOptions, itemType =>
#elif NET40_OR_GREATER
Parallel.ForEach(typeDats.Keys, itemType =>
#else
foreach (var itemType in typeDats.Keys)
#endif
{ {
Writer.Write(typeDats[itemType], OutputDir); Writer.Write(typeDats[itemType], OutputDir);
#if NET40_OR_GREATER || NETCOREAPP #if NET40_OR_GREATER || NETCOREAPP

View File

@@ -153,7 +153,13 @@ namespace SabreTools.Features
if (updateMode == UpdateMode.None) if (updateMode == UpdateMode.None)
{ {
// Loop through each input and update // Loop through each input and update
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath => Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath =>
#elif NET40_OR_GREATER
Parallel.ForEach(inputPaths, inputPath =>
#else
foreach (var inputPath in inputPaths)
#endif
{ {
// Create a new base DatFile // Create a new base DatFile
DatFile datFile = DatFile.Create(Header); DatFile datFile = DatFile.Create(Header);
@@ -242,13 +248,23 @@ namespace SabreTools.Features
// Loop through and output the new DatFiles // Loop through and output the new DatFiles
InternalStopwatch watch = new("Outputting all individual DATs"); InternalStopwatch watch = new("Outputting all individual DATs");
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, inputPaths.Count, Globals.ParallelOptions, j => Parallel.For(0, inputPaths.Count, Globals.ParallelOptions, j =>
#elif NET40_OR_GREATER
Parallel.For(0, inputPaths.Count, j =>
#else
for (int j = 0; j < inputPaths.Count; j++)
#endif
{ {
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue)); string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
// Try to output the file // Try to output the file
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue)); Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
watch.Stop(); watch.Stop();
} }
@@ -257,7 +273,13 @@ namespace SabreTools.Features
if (updateMode.HasFlag(UpdateMode.DiffCascade)) if (updateMode.HasFlag(UpdateMode.DiffCascade))
{ {
// Preprocess the DatHeaders // Preprocess the DatHeaders
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(0, datHeaders.Count, Globals.ParallelOptions, j => Parallel.For(0, datHeaders.Count, Globals.ParallelOptions, j =>
#elif NET40_OR_GREATER
Parallel.For(0, datHeaders.Count, j =>
#else
for (int j = 0; j < datHeaders.Count; j++)
#endif
{ {
// If we're outputting to the runtime folder, rename // If we're outputting to the runtime folder, rename
if (!GetBoolean(features, InplaceValue) && OutputDir == Environment.CurrentDirectory) if (!GetBoolean(features, InplaceValue) && OutputDir == Environment.CurrentDirectory)
@@ -269,7 +291,11 @@ namespace SabreTools.Features
datHeaders[j].Name += innerpost; datHeaders[j].Name += innerpost;
datHeaders[j].Description += innerpost; datHeaders[j].Description += innerpost;
} }
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
// Get all of the output DatFiles // Get all of the output DatFiles
List<DatFile> datFiles = DatFileTool.DiffCascade(userInputDat, datHeaders); List<DatFile> datFiles = DatFileTool.DiffCascade(userInputDat, datHeaders);
@@ -278,13 +304,23 @@ namespace SabreTools.Features
InternalStopwatch watch = new("Outputting all created DATs"); InternalStopwatch watch = new("Outputting all created DATs");
int startIndex = GetBoolean(features, SkipFirstOutputValue) ? 1 : 0; int startIndex = GetBoolean(features, SkipFirstOutputValue) ? 1 : 0;
#if NET452_OR_GREATER || NETCOREAPP
Parallel.For(startIndex, inputPaths.Count, Globals.ParallelOptions, j => Parallel.For(startIndex, inputPaths.Count, Globals.ParallelOptions, j =>
#elif NET40_OR_GREATER
Parallel.For(startIndex, inputPaths.Count, j =>
#else
for (int j = startIndex; j < inputPaths.Count; j++)
#endif
{ {
string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue)); string path = inputPaths[j].GetOutputPath(OutputDir, GetBoolean(features, InplaceValue));
// Try to output the file // Try to output the file
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue)); Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
#if NET40_OR_GREATER || NETCOREAPP
}); });
#else
}
#endif
watch.Stop(); watch.Stop();
} }
@@ -293,7 +329,13 @@ namespace SabreTools.Features
if (updateMode.HasFlag(UpdateMode.DiffAgainst)) if (updateMode.HasFlag(UpdateMode.DiffAgainst))
{ {
// Loop through each input and diff against the base // Loop through each input and diff against the base
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath => Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath =>
#elif NET40_OR_GREATER
Parallel.ForEach(inputPaths, inputPath =>
#else
foreach (var inputPath in inputPaths)
#endif
{ {
// Parse the path to a new DatFile // Parse the path to a new DatFile
DatFile repDat = DatFile.Create(Header); DatFile repDat = DatFile.Create(Header);
@@ -323,7 +365,13 @@ namespace SabreTools.Features
if (updateMode.HasFlag(UpdateMode.BaseReplace)) if (updateMode.HasFlag(UpdateMode.BaseReplace))
{ {
// Loop through each input and apply the base DatFile // Loop through each input and apply the base DatFile
#if NET452_OR_GREATER || NETCOREAPP
Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath => Parallel.ForEach(inputPaths, Globals.ParallelOptions, inputPath =>
#elif NET40_OR_GREATER
Parallel.ForEach(inputPaths, inputPath =>
#else
foreach (var inputPath in inputPaths)
#endif
{ {
// Parse the path to a new DatFile // Parse the path to a new DatFile
DatFile repDat = DatFile.Create(Header); DatFile repDat = DatFile.Create(Header);