mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Support ancient .NET in DatFiles
This commit is contained in:
@@ -123,19 +123,19 @@ namespace SabreTools.DatFiles
|
||||
public void FillHeaderFromPath(string path, bool bare)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
|
||||
// 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})");
|
||||
}
|
||||
|
||||
// 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);
|
||||
Header.Name = splitpath.Last();
|
||||
@@ -172,8 +172,8 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (disk.ItemStatus != ItemStatus.Nodump
|
||||
&& string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
&& string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
logger.Verbose($"Incomplete entry for '{disk.Name}' will be output as nodump");
|
||||
disk.ItemStatus = ItemStatus.Nodump;
|
||||
@@ -184,10 +184,10 @@ namespace SabreTools.DatFiles
|
||||
if (item.ItemType == ItemType.Media && item is Media media)
|
||||
{
|
||||
// If the file has aboslutely no hashes, skip and log
|
||||
if (string.IsNullOrWhiteSpace(media.MD5)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(media.SpamSum))
|
||||
if (string.IsNullOrEmpty(media.MD5)
|
||||
&& string.IsNullOrEmpty(media.SHA1)
|
||||
&& string.IsNullOrEmpty(media.SHA256)
|
||||
&& string.IsNullOrEmpty(media.SpamSum))
|
||||
{
|
||||
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
|
||||
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
|
||||
rom.Size = Constants.SizeZero;
|
||||
@@ -262,7 +262,7 @@ namespace SabreTools.DatFiles
|
||||
protected static string? CleanDate(string? input)
|
||||
{
|
||||
// Null in, null out
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
if (string.IsNullOrEmpty(input))
|
||||
return null;
|
||||
|
||||
string date = string.Empty;
|
||||
@@ -409,7 +409,7 @@ namespace SabreTools.DatFiles
|
||||
if (item.ItemType == ItemType.Disk && item is Disk disk)
|
||||
{
|
||||
// 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('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
@@ -418,7 +418,7 @@ namespace SabreTools.DatFiles
|
||||
else if (item.ItemType == ItemType.Media && item is Media media)
|
||||
{
|
||||
// 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('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
@@ -427,7 +427,7 @@ namespace SabreTools.DatFiles
|
||||
else if (item.ItemType == ItemType.Rom && item is Rom rom)
|
||||
{
|
||||
// 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('\\', '/');
|
||||
item.SetName($"{pre}{name}{post}");
|
||||
@@ -437,7 +437,7 @@ namespace SabreTools.DatFiles
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Header.ReplaceExtension) || Header.RemoveExtension)
|
||||
if (!string.IsNullOrEmpty(Header.ReplaceExtension) || Header.RemoveExtension)
|
||||
{
|
||||
if (Header.RemoveExtension)
|
||||
Header.ReplaceExtension = string.Empty;
|
||||
@@ -450,7 +450,7 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(Header.AddExtension))
|
||||
if (!string.IsNullOrEmpty(Header.AddExtension))
|
||||
name += Header.AddExtension;
|
||||
|
||||
if (Header.UseRomName && Header.GameName)
|
||||
@@ -597,7 +597,11 @@ namespace SabreTools.DatFiles
|
||||
if (missingFields != null && missingFields.Count != 0)
|
||||
{
|
||||
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)}");
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -656,46 +656,46 @@ namespace SabreTools.DatFiles
|
||||
if (datHeader == null)
|
||||
return;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.FileName))
|
||||
if (!string.IsNullOrEmpty(datHeader.FileName))
|
||||
FileName = datHeader.FileName;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Name))
|
||||
if (!string.IsNullOrEmpty(datHeader.Name))
|
||||
Name = datHeader.Name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Description))
|
||||
if (!string.IsNullOrEmpty(datHeader.Description))
|
||||
Description = datHeader.Description;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.RootDir))
|
||||
if (!string.IsNullOrEmpty(datHeader.RootDir))
|
||||
RootDir = datHeader.RootDir;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Category))
|
||||
if (!string.IsNullOrEmpty(datHeader.Category))
|
||||
Category = datHeader.Category;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Version))
|
||||
if (!string.IsNullOrEmpty(datHeader.Version))
|
||||
Version = datHeader.Version;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Date))
|
||||
if (!string.IsNullOrEmpty(datHeader.Date))
|
||||
Date = datHeader.Date;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Author))
|
||||
if (!string.IsNullOrEmpty(datHeader.Author))
|
||||
Author = datHeader.Author;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Email))
|
||||
if (!string.IsNullOrEmpty(datHeader.Email))
|
||||
Email = datHeader.Email;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Homepage))
|
||||
if (!string.IsNullOrEmpty(datHeader.Homepage))
|
||||
Homepage = datHeader.Homepage;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Url))
|
||||
if (!string.IsNullOrEmpty(datHeader.Url))
|
||||
Url = datHeader.Url;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Comment))
|
||||
if (!string.IsNullOrEmpty(datHeader.Comment))
|
||||
Comment = datHeader.Comment;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.HeaderSkipper))
|
||||
if (!string.IsNullOrEmpty(datHeader.HeaderSkipper))
|
||||
HeaderSkipper = datHeader.HeaderSkipper;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Type))
|
||||
if (!string.IsNullOrEmpty(datHeader.Type))
|
||||
Type = datHeader.Type;
|
||||
|
||||
if (datHeader.ForceMerging != MergingFlag.None)
|
||||
@@ -710,16 +710,16 @@ namespace SabreTools.DatFiles
|
||||
if (datHeader.DatFormat != 0x00)
|
||||
DatFormat = datHeader.DatFormat;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Prefix))
|
||||
if (!string.IsNullOrEmpty(datHeader.Prefix))
|
||||
Prefix = datHeader.Prefix;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.Postfix))
|
||||
if (!string.IsNullOrEmpty(datHeader.Postfix))
|
||||
Postfix = datHeader.Postfix;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.AddExtension))
|
||||
if (!string.IsNullOrEmpty(datHeader.AddExtension))
|
||||
AddExtension = datHeader.AddExtension;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(datHeader.ReplaceExtension))
|
||||
if (!string.IsNullOrEmpty(datHeader.ReplaceExtension))
|
||||
ReplaceExtension = datHeader.ReplaceExtension;
|
||||
|
||||
RemoveExtension = datHeader.RemoveExtension;
|
||||
@@ -757,7 +757,11 @@ namespace SabreTools.DatFiles
|
||||
#region .csv
|
||||
|
||||
// CSV
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.CSV) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.CSV))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.CSV, CreateOutFileNamesHelper(outDir, ".csv", overwrite));
|
||||
usedExtensions.Add(".csv");
|
||||
@@ -768,14 +772,22 @@ namespace SabreTools.DatFiles
|
||||
#region .dat
|
||||
|
||||
// ClrMamePro
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.ClrMamePro) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.ClrMamePro))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.ClrMamePro, CreateOutFileNamesHelper(outDir, ".dat", overwrite));
|
||||
usedExtensions.Add(".dat");
|
||||
};
|
||||
|
||||
// RomCenter
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RomCenter) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RomCenter))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".dat"))
|
||||
{
|
||||
@@ -790,7 +802,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// DOSCenter
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.DOSCenter) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.DOSCenter))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".dat"))
|
||||
{
|
||||
@@ -809,7 +825,11 @@ namespace SabreTools.DatFiles
|
||||
#region .json
|
||||
|
||||
// JSON
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.SabreJSON) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.SabreJSON))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.SabreJSON, CreateOutFileNamesHelper(outDir, ".json", overwrite));
|
||||
usedExtensions.Add(".json");
|
||||
@@ -820,7 +840,11 @@ namespace SabreTools.DatFiles
|
||||
#region .md5
|
||||
|
||||
// Redump MD5
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpMD5) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpMD5))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpMD5, CreateOutFileNamesHelper(outDir, ".md5", overwrite));
|
||||
usedExtensions.Add(".md5");
|
||||
@@ -831,7 +855,11 @@ namespace SabreTools.DatFiles
|
||||
#region .sfv
|
||||
|
||||
// Redump SFV
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSFV) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSFV))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSFV, CreateOutFileNamesHelper(outDir, ".sfv", overwrite));
|
||||
usedExtensions.Add(".sfv");
|
||||
@@ -842,7 +870,11 @@ namespace SabreTools.DatFiles
|
||||
#region .sha1
|
||||
|
||||
// Redump SHA-1
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSHA1) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSHA1))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSHA1, CreateOutFileNamesHelper(outDir, ".sha1", overwrite));
|
||||
usedExtensions.Add(".sha1");
|
||||
@@ -853,7 +885,11 @@ namespace SabreTools.DatFiles
|
||||
#region .sha256
|
||||
|
||||
// Redump SHA-256
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSHA256) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSHA256))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSHA256, CreateOutFileNamesHelper(outDir, ".sha256", overwrite));
|
||||
usedExtensions.Add(".sha256");
|
||||
@@ -864,7 +900,11 @@ namespace SabreTools.DatFiles
|
||||
#region .sha384
|
||||
|
||||
// Redump SHA-384
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSHA384) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSHA384))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSHA384, CreateOutFileNamesHelper(outDir, ".sha384", overwrite));
|
||||
usedExtensions.Add(".sha384");
|
||||
@@ -875,7 +915,11 @@ namespace SabreTools.DatFiles
|
||||
#region .sha512
|
||||
|
||||
// Redump SHA-512
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSHA512) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSHA512))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSHA512, CreateOutFileNamesHelper(outDir, ".sha512", overwrite));
|
||||
usedExtensions.Add(".sha512");
|
||||
@@ -886,7 +930,11 @@ namespace SabreTools.DatFiles
|
||||
#region .spamsum
|
||||
|
||||
// Redump SpamSum
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.RedumpSpamSum) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.RedumpSpamSum))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.RedumpSpamSum, CreateOutFileNamesHelper(outDir, ".spamsum", overwrite));
|
||||
usedExtensions.Add(".spamsum");
|
||||
@@ -897,7 +945,11 @@ namespace SabreTools.DatFiles
|
||||
#region .ssv
|
||||
|
||||
// SSV
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.SSV) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.SSV))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.SSV, CreateOutFileNamesHelper(outDir, ".ssv", overwrite));
|
||||
usedExtensions.Add(".ssv");
|
||||
@@ -908,7 +960,11 @@ namespace SabreTools.DatFiles
|
||||
#region .tsv
|
||||
|
||||
// TSV
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.TSV) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.TSV))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.TSV, CreateOutFileNamesHelper(outDir, ".tsv", overwrite));
|
||||
usedExtensions.Add(".tsv");
|
||||
@@ -919,14 +975,22 @@ namespace SabreTools.DatFiles
|
||||
#region .txt
|
||||
|
||||
// AttractMode
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.AttractMode) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.AttractMode))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.AttractMode, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
|
||||
usedExtensions.Add(".txt");
|
||||
}
|
||||
|
||||
// MAME Listroms
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.Listrom) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.Listrom))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".txt"))
|
||||
{
|
||||
@@ -941,7 +1005,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Missfile
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.MissFile) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.MissFile))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".txt"))
|
||||
{
|
||||
@@ -956,7 +1024,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Everdrive SMDB
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.EverdriveSMDB) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.EverdriveSMDB))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".txt"))
|
||||
{
|
||||
@@ -975,19 +1047,31 @@ namespace SabreTools.DatFiles
|
||||
#region .xml
|
||||
|
||||
// Logiqx XML
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.Logiqx) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.Logiqx))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.Logiqx, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
||||
usedExtensions.Add(".xml");
|
||||
}
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.LogiqxDeprecated) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.LogiqxDeprecated))
|
||||
#endif
|
||||
{
|
||||
outfileNames.Add(DatFormat.LogiqxDeprecated, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
||||
usedExtensions.Add(".xml");
|
||||
}
|
||||
|
||||
// SabreDAT
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.SabreXML) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.SabreXML))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1002,7 +1086,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Software List
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.SoftwareList) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.SoftwareList))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1017,7 +1105,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// MAME Listxml
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.Listxml) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.Listxml))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1032,7 +1124,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// OfflineList
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.OfflineList) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.OfflineList))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1047,7 +1143,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// openMSX
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.OpenMSX) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.OpenMSX))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1062,7 +1162,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Archive.org
|
||||
#if NETFRAMEWORK
|
||||
if ((DatFormat & DatFormat.ArchiveDotOrg) != 0)
|
||||
#else
|
||||
if (DatFormat.HasFlag(DatFormat.ArchiveDotOrg))
|
||||
#endif
|
||||
{
|
||||
if (usedExtensions.Contains(".xml"))
|
||||
{
|
||||
@@ -1090,7 +1194,7 @@ namespace SabreTools.DatFiles
|
||||
/// <returns>String containing the new filename</returns>
|
||||
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
|
||||
if (Utilities.HasValidDatExtension(filename))
|
||||
|
||||
@@ -41,21 +41,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return (null, null);
|
||||
|
||||
string machineName = Path.GetFileNameWithoutExtension(filename);
|
||||
if (filename.Contains('/'))
|
||||
{
|
||||
string[] split = filename.Split('/');
|
||||
string[] split = filename!.Split('/');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
else if (filename.Contains('\\'))
|
||||
{
|
||||
string[] split = filename.Split('\\');
|
||||
string[] split = filename!.Split('\\');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
|
||||
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="indexId">Index ID for the DAT</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)
|
||||
#endif
|
||||
{
|
||||
// If the files array is missing, we can't do anything
|
||||
if (files == null || !files.Any())
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
@@ -35,9 +35,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
case Rom rom:
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
if (string.IsNullOrEmpty(rom.CRC)
|
||||
&& string.IsNullOrEmpty(rom.MD5)
|
||||
&& string.IsNullOrEmpty(rom.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
return missingFields;
|
||||
|
||||
@@ -41,60 +41,60 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (datItem)
|
||||
{
|
||||
case Release release:
|
||||
if (string.IsNullOrWhiteSpace(release.Name))
|
||||
if (string.IsNullOrEmpty(release.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(release.Region))
|
||||
if (string.IsNullOrEmpty(release.Region))
|
||||
missingFields.Add(DatItemField.Region);
|
||||
break;
|
||||
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrWhiteSpace(biosset.Name))
|
||||
if (string.IsNullOrEmpty(biosset.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(biosset.Description))
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(DatItemField.Description);
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.Name))
|
||||
if (string.IsNullOrEmpty(rom.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA512)
|
||||
&& string.IsNullOrWhiteSpace(rom.SpamSum))
|
||||
if (string.IsNullOrEmpty(rom.CRC)
|
||||
&& string.IsNullOrEmpty(rom.MD5)
|
||||
&& string.IsNullOrEmpty(rom.SHA1)
|
||||
&& string.IsNullOrEmpty(rom.SHA256)
|
||||
&& string.IsNullOrEmpty(rom.SHA384)
|
||||
&& string.IsNullOrEmpty(rom.SHA512)
|
||||
&& string.IsNullOrEmpty(rom.SpamSum))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Disk disk:
|
||||
if (string.IsNullOrWhiteSpace(disk.Name))
|
||||
if (string.IsNullOrEmpty(disk.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
if (string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Sample sample:
|
||||
if (string.IsNullOrWhiteSpace(sample.Name))
|
||||
if (string.IsNullOrEmpty(sample.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Archive archive:
|
||||
if (string.IsNullOrWhiteSpace(archive.Name))
|
||||
if (string.IsNullOrEmpty(archive.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Chip chip:
|
||||
if (!chip.ChipTypeSpecified)
|
||||
missingFields.Add(DatItemField.ChipType);
|
||||
if (string.IsNullOrWhiteSpace(chip.Name))
|
||||
if (string.IsNullOrEmpty(chip.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case DipSwitch dipswitch:
|
||||
if (string.IsNullOrWhiteSpace(dipswitch.Name))
|
||||
if (string.IsNullOrEmpty(dipswitch.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
@@ -35,9 +35,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
case Rom rom:
|
||||
if (!rom.SizeSpecified)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
// if (string.IsNullOrWhiteSpace(rom.Date))
|
||||
// if (string.IsNullOrEmpty(rom.Date))
|
||||
// missingFields.Add(DatItemField.Date);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC))
|
||||
if (string.IsNullOrEmpty(rom.CRC))
|
||||
missingFields.Add(DatItemField.CRC);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -41,21 +41,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return (null, null);
|
||||
|
||||
string machineName = Path.GetFileNameWithoutExtension(filename);
|
||||
if (filename.Contains('/'))
|
||||
{
|
||||
string[] split = filename.Split('/');
|
||||
string[] split = filename!.Split('/');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
else if (filename.Contains('\\'))
|
||||
{
|
||||
string[] split = filename.Split('\\');
|
||||
string[] split = filename!.Split('\\');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
|
||||
var machine = new Machine { Name = machineName };
|
||||
|
||||
@@ -27,19 +27,19 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.SHA256))
|
||||
if (string.IsNullOrEmpty(rom.SHA256))
|
||||
missingFields.Add(DatItemField.SHA256);
|
||||
if (string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
if (string.IsNullOrEmpty(rom.SHA1))
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
if (string.IsNullOrWhiteSpace(rom.MD5))
|
||||
if (string.IsNullOrEmpty(rom.MD5))
|
||||
missingFields.Add(DatItemField.MD5);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC))
|
||||
if (string.IsNullOrEmpty(rom.CRC))
|
||||
missingFields.Add(DatItemField.CRC);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static (Machine?, string?) DeriveMachine(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return (null, null);
|
||||
|
||||
string machineName = Path.GetFileNameWithoutExtension(filename);
|
||||
if (filename.Contains('/'))
|
||||
{
|
||||
string[] split = filename.Split('/');
|
||||
string[] split = filename!.Split('/');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
else if (filename.Contains('\\'))
|
||||
{
|
||||
string[] split = filename.Split('\\');
|
||||
string[] split = filename!.Split('\\');
|
||||
machineName = split[0];
|
||||
filename = filename[(machineName.Length + 1)..];
|
||||
filename = filename.Substring(machineName.Length + 1);
|
||||
}
|
||||
|
||||
var machine = new Machine { Name = machineName };
|
||||
@@ -92,11 +92,11 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static ItemType DeriveItemType(string? filename)
|
||||
{
|
||||
// If the filename is missing, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
if (string.IsNullOrEmpty(filename))
|
||||
return ItemType.NULL;
|
||||
|
||||
// If we end in the CHD extension
|
||||
if (filename.EndsWith(".chd", StringComparison.OrdinalIgnoreCase))
|
||||
if (filename!.EndsWith(".chd", StringComparison.OrdinalIgnoreCase))
|
||||
return ItemType.Disk;
|
||||
|
||||
// If we end in an Aaruformat extension
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
// Check hash linked to specific Hashfile type
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Create the machine
|
||||
Machine machine;
|
||||
if (!string.IsNullOrWhiteSpace(set.Device))
|
||||
if (!string.IsNullOrEmpty(set.Device))
|
||||
{
|
||||
machine = new Machine
|
||||
{
|
||||
@@ -75,7 +75,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
MachineType = MachineType.Device,
|
||||
};
|
||||
}
|
||||
else if (!string.IsNullOrWhiteSpace(set.Driver))
|
||||
else if (!string.IsNullOrEmpty(set.Driver))
|
||||
{
|
||||
machine = new Machine
|
||||
{
|
||||
@@ -111,8 +111,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (row.Size == null
|
||||
&& !row.NoGoodDumpKnown
|
||||
&& !row.Bad
|
||||
&& (!string.IsNullOrWhiteSpace(row.MD5)
|
||||
|| !string.IsNullOrWhiteSpace(row.SHA1)))
|
||||
&& (!string.IsNullOrEmpty(row.MD5)
|
||||
|| !string.IsNullOrEmpty(row.SHA1)))
|
||||
{
|
||||
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;
|
||||
else
|
||||
disk.SHA1 = row.SHA1;
|
||||
@@ -165,8 +165,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
else if (row.Size == null
|
||||
&& !row.NoGoodDumpKnown
|
||||
&& row.Bad
|
||||
&& (!string.IsNullOrWhiteSpace(row.MD5)
|
||||
|| !string.IsNullOrWhiteSpace(row.SHA1)))
|
||||
&& (!string.IsNullOrEmpty(row.MD5)
|
||||
|| !string.IsNullOrEmpty(row.SHA1)))
|
||||
{
|
||||
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;
|
||||
else
|
||||
disk.SHA1 = row.SHA1;
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Disk disk:
|
||||
if (string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
if (string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
@@ -44,9 +44,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
case Rom rom:
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC))
|
||||
if (string.IsNullOrEmpty(rom.CRC))
|
||||
missingFields.Add(DatItemField.CRC);
|
||||
if (string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
if (string.IsNullOrEmpty(rom.SHA1))
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
break;
|
||||
}
|
||||
@@ -116,8 +116,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
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,
|
||||
Device = items[0]!.Machine!.MachineType.HasFlag(MachineType.Device) ? items[0]!.Machine!.Name : null,
|
||||
#endif
|
||||
};
|
||||
|
||||
// Loop through and convert the items to respective lists
|
||||
@@ -177,7 +182,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Bad = true,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(disk.MD5))
|
||||
if (!string.IsNullOrEmpty(disk.MD5))
|
||||
row.MD5 = disk.MD5;
|
||||
else
|
||||
row.SHA1 = disk.SHA1;
|
||||
@@ -191,7 +196,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Name = disk.Name,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(disk.MD5))
|
||||
if (!string.IsNullOrEmpty(disk.MD5))
|
||||
row.MD5 = disk.MD5;
|
||||
else
|
||||
row.SHA1 = disk.SHA1;
|
||||
|
||||
@@ -48,46 +48,46 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (datItem)
|
||||
{
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrWhiteSpace(biosset.Name))
|
||||
if (string.IsNullOrEmpty(biosset.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(biosset.Description))
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(DatItemField.Description);
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.Name))
|
||||
if (string.IsNullOrEmpty(rom.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
if (string.IsNullOrEmpty(rom.CRC)
|
||||
&& string.IsNullOrEmpty(rom.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Disk disk:
|
||||
if (string.IsNullOrWhiteSpace(disk.Name))
|
||||
if (string.IsNullOrEmpty(disk.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
if (string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceReference deviceref:
|
||||
if (string.IsNullOrWhiteSpace(deviceref.Name))
|
||||
if (string.IsNullOrEmpty(deviceref.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Sample sample:
|
||||
if (string.IsNullOrWhiteSpace(sample.Name))
|
||||
if (string.IsNullOrEmpty(sample.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Chip chip:
|
||||
if (string.IsNullOrWhiteSpace(chip.Name))
|
||||
if (string.IsNullOrEmpty(chip.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (!chip.ChipTypeSpecified)
|
||||
missingFields.Add(DatItemField.ChipType);
|
||||
@@ -111,26 +111,26 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case DipSwitch dipswitch:
|
||||
if (string.IsNullOrWhiteSpace(dipswitch.Name))
|
||||
if (string.IsNullOrEmpty(dipswitch.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(dipswitch.Tag))
|
||||
if (string.IsNullOrEmpty(dipswitch.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
break;
|
||||
|
||||
case Configuration configuration:
|
||||
if (string.IsNullOrWhiteSpace(configuration.Name))
|
||||
if (string.IsNullOrEmpty(configuration.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(configuration.Tag))
|
||||
if (string.IsNullOrEmpty(configuration.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
break;
|
||||
|
||||
case Port port:
|
||||
if (string.IsNullOrWhiteSpace(port.Tag))
|
||||
if (string.IsNullOrEmpty(port.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
break;
|
||||
|
||||
case Adjuster adjuster:
|
||||
if (string.IsNullOrWhiteSpace(adjuster.Name))
|
||||
if (string.IsNullOrEmpty(adjuster.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
@@ -156,21 +156,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case Slot slot:
|
||||
if (string.IsNullOrWhiteSpace(slot.Name))
|
||||
if (string.IsNullOrEmpty(slot.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case DatItems.Formats.SoftwareList softwarelist:
|
||||
if (string.IsNullOrWhiteSpace(softwarelist.Tag))
|
||||
if (string.IsNullOrEmpty(softwarelist.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
if (string.IsNullOrWhiteSpace(softwarelist.Name))
|
||||
if (string.IsNullOrEmpty(softwarelist.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (!softwarelist.StatusSpecified)
|
||||
missingFields.Add(DatItemField.SoftwareListStatus);
|
||||
break;
|
||||
|
||||
case RamOption ramoption:
|
||||
if (string.IsNullOrWhiteSpace(ramoption.Name))
|
||||
if (string.IsNullOrEmpty(ramoption.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
}
|
||||
@@ -384,12 +384,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
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))
|
||||
game.IsBios = "yes";
|
||||
if (machine.MachineType.HasFlag(MachineType.Device))
|
||||
game.IsDevice = "yes";
|
||||
if (machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
game.IsMechanical = "yes";
|
||||
#endif
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
Publisher = game.Publisher,
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dirname))
|
||||
if (!string.IsNullOrEmpty(dirname))
|
||||
machine.Name = $"{dirname}/{machine.Name}";
|
||||
|
||||
if (game.IsBios.AsYesNo() == true)
|
||||
@@ -236,10 +236,17 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (game.IsMechanical.AsYesNo() == true)
|
||||
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())
|
||||
machine.Comment = string.Join(';', game.Comment);
|
||||
if (game.Category != null && game.Category.Any())
|
||||
machine.Category = string.Join(';', game.Category);
|
||||
#endif
|
||||
|
||||
if (game.Trurip != null)
|
||||
{
|
||||
|
||||
@@ -35,70 +35,70 @@ namespace SabreTools.DatFiles.Formats
|
||||
switch (datItem)
|
||||
{
|
||||
case Release release:
|
||||
if (string.IsNullOrWhiteSpace(release.Name))
|
||||
if (string.IsNullOrEmpty(release.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(release.Region))
|
||||
if (string.IsNullOrEmpty(release.Region))
|
||||
missingFields.Add(DatItemField.Region);
|
||||
break;
|
||||
|
||||
case BiosSet biosset:
|
||||
if (string.IsNullOrWhiteSpace(biosset.Name))
|
||||
if (string.IsNullOrEmpty(biosset.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(biosset.Description))
|
||||
if (string.IsNullOrEmpty(biosset.Description))
|
||||
missingFields.Add(DatItemField.Description);
|
||||
break;
|
||||
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.Name))
|
||||
if (string.IsNullOrEmpty(rom.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA512)
|
||||
&& string.IsNullOrWhiteSpace(rom.SpamSum))
|
||||
if (string.IsNullOrEmpty(rom.CRC)
|
||||
&& string.IsNullOrEmpty(rom.MD5)
|
||||
&& string.IsNullOrEmpty(rom.SHA1)
|
||||
&& string.IsNullOrEmpty(rom.SHA256)
|
||||
&& string.IsNullOrEmpty(rom.SHA384)
|
||||
&& string.IsNullOrEmpty(rom.SHA512)
|
||||
&& string.IsNullOrEmpty(rom.SpamSum))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Disk disk:
|
||||
if (string.IsNullOrWhiteSpace(disk.Name))
|
||||
if (string.IsNullOrEmpty(disk.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
if (string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Media media:
|
||||
if (string.IsNullOrWhiteSpace(media.Name))
|
||||
if (string.IsNullOrEmpty(media.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(media.MD5)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(media.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(media.SpamSum))
|
||||
if (string.IsNullOrEmpty(media.MD5)
|
||||
&& string.IsNullOrEmpty(media.SHA1)
|
||||
&& string.IsNullOrEmpty(media.SHA256)
|
||||
&& string.IsNullOrEmpty(media.SpamSum))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
break;
|
||||
|
||||
case DeviceReference deviceref:
|
||||
if (string.IsNullOrWhiteSpace(deviceref.Name))
|
||||
if (string.IsNullOrEmpty(deviceref.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Sample sample:
|
||||
if (string.IsNullOrWhiteSpace(sample.Name))
|
||||
if (string.IsNullOrEmpty(sample.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Archive archive:
|
||||
if (string.IsNullOrWhiteSpace(archive.Name))
|
||||
if (string.IsNullOrEmpty(archive.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
@@ -114,9 +114,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case DatItems.Formats.SoftwareList softwarelist:
|
||||
if (string.IsNullOrWhiteSpace(softwarelist.Tag))
|
||||
if (string.IsNullOrEmpty(softwarelist.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
if (string.IsNullOrWhiteSpace(softwarelist.Name))
|
||||
if (string.IsNullOrEmpty(softwarelist.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (!softwarelist.StatusSpecified)
|
||||
missingFields.Add(DatItemField.SoftwareListStatus);
|
||||
@@ -137,7 +137,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
// Only write the doctype if we don't have No-Intro data
|
||||
bool success;
|
||||
if (string.IsNullOrWhiteSpace(Header.NoIntroID))
|
||||
if (string.IsNullOrEmpty(Header.NoIntroID))
|
||||
success = new Serialization.Files.Logiqx().SerializeToFileWithDocType(datafile, outfile);
|
||||
else
|
||||
success = new Serialization.Files.Logiqx().Serialize(datafile, outfile);
|
||||
@@ -222,7 +222,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
if (!Header.ForceMergingSpecified
|
||||
&& !Header.ForceNodumpSpecified
|
||||
&& !Header.ForcePackingSpecified
|
||||
&& string.IsNullOrWhiteSpace(Header.HeaderSkipper))
|
||||
&& string.IsNullOrEmpty(Header.HeaderSkipper))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
private Models.Logiqx.RomCenter? CreateRomCenter()
|
||||
{
|
||||
// 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.BiosModeSpecified
|
||||
&& !Header.SampleModeSpecified
|
||||
@@ -391,12 +391,21 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
game.Name = machine.Name;
|
||||
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))
|
||||
game.IsBios = "yes";
|
||||
if (machine.MachineType.HasFlag(MachineType.Device))
|
||||
game.IsDevice = "yes";
|
||||
if (machine.MachineType.HasFlag(MachineType.Mechanical))
|
||||
game.IsMechanical = "yes";
|
||||
#endif
|
||||
game.CloneOf = machine.CloneOf;
|
||||
game.RomOf = machine.RomOf;
|
||||
game.SampleOf = machine.SampleOf;
|
||||
@@ -434,15 +443,15 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static Models.Logiqx.Trurip? CreateTrurip(Machine machine)
|
||||
{
|
||||
// If we don't have subheader values, we can't do anything
|
||||
if (string.IsNullOrWhiteSpace(machine.TitleID)
|
||||
&& string.IsNullOrWhiteSpace(machine.Developer)
|
||||
&& string.IsNullOrWhiteSpace(machine.Genre)
|
||||
&& string.IsNullOrWhiteSpace(machine.Subgenre)
|
||||
&& string.IsNullOrWhiteSpace(machine.Ratings)
|
||||
&& string.IsNullOrWhiteSpace(machine.Score)
|
||||
&& string.IsNullOrWhiteSpace(machine.Enabled)
|
||||
if (string.IsNullOrEmpty(machine.TitleID)
|
||||
&& string.IsNullOrEmpty(machine.Developer)
|
||||
&& string.IsNullOrEmpty(machine.Genre)
|
||||
&& string.IsNullOrEmpty(machine.Subgenre)
|
||||
&& string.IsNullOrEmpty(machine.Ratings)
|
||||
&& string.IsNullOrEmpty(machine.Score)
|
||||
&& string.IsNullOrEmpty(machine.Enabled)
|
||||
&& !machine.CrcSpecified
|
||||
&& string.IsNullOrWhiteSpace(machine.RelatedTo))
|
||||
&& string.IsNullOrEmpty(machine.RelatedTo))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
foreach (var crc in files.RomCRC)
|
||||
{
|
||||
string name = string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(releaseNumber) && releaseNumber != "0")
|
||||
if (!string.IsNullOrEmpty(releaseNumber) && releaseNumber != "0")
|
||||
name += $"{releaseNumber} - ";
|
||||
name += $"{machine.Name}{crc.Extension}";
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
@@ -34,7 +34,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
case Rom rom:
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC))
|
||||
if (string.IsNullOrEmpty(rom.CRC))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
|
||||
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
|
||||
{
|
||||
Name = name,
|
||||
|
||||
@@ -26,13 +26,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
{
|
||||
var missingFields = new List<DatItemField>();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.SHA1))
|
||||
if (string.IsNullOrEmpty(rom.SHA1))
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Rom rom:
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC))
|
||||
if (string.IsNullOrEmpty(rom.CRC))
|
||||
missingFields.Add(DatItemField.CRC);
|
||||
if (!rom.SizeSpecified)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
|
||||
@@ -457,8 +457,8 @@ namespace SabreTools.DatFiles.Formats
|
||||
private static void WriteStartGame(JsonTextWriter jtw, DatItem datItem)
|
||||
{
|
||||
// No game should start with a path separator
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.Name))
|
||||
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
|
||||
if (!string.IsNullOrEmpty(datItem.Machine.Name))
|
||||
datItem.Machine.Name = datItem.Machine.Name!.TrimStart(Path.DirectorySeparatorChar);
|
||||
|
||||
// Build the state
|
||||
jtw.WriteStartObject();
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
XmlReader? xtr = XmlReader.Create(filename, new XmlReaderSettings
|
||||
{
|
||||
CheckCharacters = false,
|
||||
#if NET40_OR_GREATER
|
||||
DtdProcessing = DtdProcessing.Ignore,
|
||||
#endif
|
||||
IgnoreComments = true,
|
||||
IgnoreWhitespace = true,
|
||||
ValidationFlags = XmlSchemaValidationFlags.None,
|
||||
@@ -83,7 +85,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
xtr?.Read();
|
||||
}
|
||||
|
||||
#if NET452_OR_GREATER
|
||||
xtr?.Dispose();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -246,7 +250,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
WriteFooter(xtw);
|
||||
|
||||
logger.User($"'{outfile}' written!{Environment.NewLine}");
|
||||
#if NET452_OR_GREATER
|
||||
xtw.Dispose();
|
||||
#endif
|
||||
fs.Dispose();
|
||||
}
|
||||
catch (Exception ex) when (!throwOnError)
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace SabreTools.DatFiles.Formats
|
||||
List<DatItemField> missingFields = [];
|
||||
|
||||
// Check item name
|
||||
if (string.IsNullOrWhiteSpace(datItem.GetName()))
|
||||
if (string.IsNullOrEmpty(datItem.GetName()))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
|
||||
switch (datItem)
|
||||
{
|
||||
case Disk disk:
|
||||
if (string.IsNullOrWhiteSpace(disk.MD5)
|
||||
&& string.IsNullOrWhiteSpace(disk.SHA1))
|
||||
if (string.IsNullOrEmpty(disk.MD5)
|
||||
&& string.IsNullOrEmpty(disk.SHA1))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
@@ -46,13 +46,13 @@ namespace SabreTools.DatFiles.Formats
|
||||
case Rom rom:
|
||||
if (rom.Size == null || rom.Size < 0)
|
||||
missingFields.Add(DatItemField.Size);
|
||||
if (string.IsNullOrWhiteSpace(rom.CRC)
|
||||
&& string.IsNullOrWhiteSpace(rom.MD5)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA1)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA256)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA384)
|
||||
&& string.IsNullOrWhiteSpace(rom.SHA512)
|
||||
&& string.IsNullOrWhiteSpace(rom.SpamSum))
|
||||
if (string.IsNullOrEmpty(rom.CRC)
|
||||
&& string.IsNullOrEmpty(rom.MD5)
|
||||
&& string.IsNullOrEmpty(rom.SHA1)
|
||||
&& string.IsNullOrEmpty(rom.SHA256)
|
||||
&& string.IsNullOrEmpty(rom.SHA384)
|
||||
&& string.IsNullOrEmpty(rom.SHA512)
|
||||
&& string.IsNullOrEmpty(rom.SpamSum))
|
||||
{
|
||||
missingFields.Add(DatItemField.SHA1);
|
||||
}
|
||||
|
||||
@@ -41,22 +41,22 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Part!.Name))
|
||||
if (string.IsNullOrEmpty(dipSwitch.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Part.Interface))
|
||||
if (string.IsNullOrEmpty(dipSwitch.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Name))
|
||||
if (string.IsNullOrEmpty(dipSwitch.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Tag))
|
||||
if (string.IsNullOrEmpty(dipSwitch.Tag))
|
||||
missingFields.Add(DatItemField.Tag);
|
||||
if (string.IsNullOrWhiteSpace(dipSwitch.Mask))
|
||||
if (string.IsNullOrEmpty(dipSwitch.Mask))
|
||||
missingFields.Add(DatItemField.Mask);
|
||||
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);
|
||||
if (dipSwitch.Values!.Any(dv => string.IsNullOrWhiteSpace(dv.Value)))
|
||||
if (dipSwitch.Values!.Any(dv => string.IsNullOrEmpty(dv.Value)))
|
||||
missingFields.Add(DatItemField.Part_Feature_Value);
|
||||
}
|
||||
|
||||
@@ -70,9 +70,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(disk.Part!.Name))
|
||||
if (string.IsNullOrEmpty(disk.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(disk.Part.Interface))
|
||||
if (string.IsNullOrEmpty(disk.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
}
|
||||
if (!disk.DiskAreaSpecified)
|
||||
@@ -81,15 +81,15 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(disk.DiskArea!.Name))
|
||||
if (string.IsNullOrEmpty(disk.DiskArea!.Name))
|
||||
missingFields.Add(DatItemField.AreaName);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(disk.Name))
|
||||
if (string.IsNullOrEmpty(disk.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
case Info info:
|
||||
if (string.IsNullOrWhiteSpace(info.Name))
|
||||
if (string.IsNullOrEmpty(info.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
|
||||
@@ -101,9 +101,9 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rom.Part!.Name))
|
||||
if (string.IsNullOrEmpty(rom.Part!.Name))
|
||||
missingFields.Add(DatItemField.Part_Name);
|
||||
if (string.IsNullOrWhiteSpace(rom.Part.Interface))
|
||||
if (string.IsNullOrEmpty(rom.Part.Interface))
|
||||
missingFields.Add(DatItemField.Part_Interface);
|
||||
}
|
||||
if (!rom.DataAreaSpecified)
|
||||
@@ -113,7 +113,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rom.DataArea!.Name))
|
||||
if (string.IsNullOrEmpty(rom.DataArea!.Name))
|
||||
missingFields.Add(DatItemField.AreaName);
|
||||
if (!rom.DataArea.SizeSpecified)
|
||||
missingFields.Add(DatItemField.AreaSize);
|
||||
@@ -121,7 +121,7 @@ namespace SabreTools.DatFiles.Formats
|
||||
break;
|
||||
|
||||
case SharedFeature sharedFeat:
|
||||
if (string.IsNullOrWhiteSpace(sharedFeat.Name))
|
||||
if (string.IsNullOrEmpty(sharedFeat.Name))
|
||||
missingFields.Add(DatItemField.Name);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Collections;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
using System.Collections.Concurrent;
|
||||
#endif
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@@ -39,7 +41,11 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Internal dictionary for the class
|
||||
/// </summary>
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
private readonly ConcurrentDictionary<string, ConcurrentList<DatItem>?> items;
|
||||
#else
|
||||
private readonly Dictionary<string, ConcurrentList<DatItem>?> items;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Lock for statistics calculation
|
||||
@@ -499,8 +505,8 @@ namespace SabreTools.DatFiles
|
||||
DiskCount++;
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -528,10 +534,10 @@ namespace SabreTools.DatFiles
|
||||
break;
|
||||
case Media media:
|
||||
MediaCount++;
|
||||
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
||||
break;
|
||||
case Part:
|
||||
PartCount++;
|
||||
@@ -556,13 +562,13 @@ namespace SabreTools.DatFiles
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += rom.Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1);
|
||||
CRCCount += (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||
}
|
||||
|
||||
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 (!items.ContainsKey(key))
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
items.TryAdd(key, []);
|
||||
#else
|
||||
items[key] = [];
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -753,7 +763,11 @@ namespace SabreTools.DatFiles
|
||||
}
|
||||
|
||||
// Remove the key from the dictionary
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
return items.TryRemove(key, out _);
|
||||
#else
|
||||
return items.Remove(key);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -867,8 +881,8 @@ namespace SabreTools.DatFiles
|
||||
DiskCount--;
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -896,9 +910,9 @@ namespace SabreTools.DatFiles
|
||||
break;
|
||||
case Media media:
|
||||
MediaCount--;
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||
break;
|
||||
case Part:
|
||||
PartCount--;
|
||||
@@ -920,12 +934,12 @@ namespace SabreTools.DatFiles
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= rom.Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
CRCCount -= (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -963,7 +977,11 @@ namespace SabreTools.DatFiles
|
||||
{
|
||||
bucketedBy = ItemKey.NULL;
|
||||
mergedBy = DedupeType.None;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
items = new ConcurrentDictionary<string, ConcurrentList<DatItem>?>();
|
||||
#else
|
||||
items = new Dictionary<string, ConcurrentList<DatItem>?>();
|
||||
#endif
|
||||
logger = new Logger(this);
|
||||
}
|
||||
|
||||
@@ -981,7 +999,11 @@ namespace SabreTools.DatFiles
|
||||
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 NET40_OR_GREATER || NETCOREAPP
|
||||
if (items == null || items.IsEmpty)
|
||||
#else
|
||||
if (items == null || items.Count == 0)
|
||||
#endif
|
||||
return;
|
||||
|
||||
// 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
|
||||
List<string> oldkeys = [.. Keys];
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (this[key] == null)
|
||||
@@ -1025,7 +1054,11 @@ namespace SabreTools.DatFiles
|
||||
// If the key is now empty, remove it
|
||||
if (this[key]!.Count == 0)
|
||||
Remove(key);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// If the merge type isn't the same, we want to merge the dictionary accordingly
|
||||
@@ -1037,7 +1070,13 @@ namespace SabreTools.DatFiles
|
||||
mergedBy = dedupeType;
|
||||
|
||||
List<string> keys = [.. Keys];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
|
||||
@@ -1064,7 +1103,13 @@ namespace SabreTools.DatFiles
|
||||
else
|
||||
{
|
||||
List<string> keys = [.. Keys];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
ConcurrentList<DatItem>? sortedlist = this[key];
|
||||
@@ -1094,11 +1139,19 @@ namespace SabreTools.DatFiles
|
||||
|
||||
// If the value is null, remove
|
||||
else if (items[key] == null)
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
items.TryRemove(key, out _);
|
||||
#else
|
||||
items.Remove(key);
|
||||
#endif
|
||||
|
||||
// If there are no non-blank items, remove
|
||||
else if (!items[key]!.Any(i => i != null && i.ItemType != ItemType.Blank))
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
items.TryRemove(key, out _);
|
||||
#else
|
||||
items.Remove(key);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
#if NET462_OR_GREATER || NETCOREAPP
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -63,11 +65,11 @@ namespace SabreTools.DatFiles
|
||||
/// <summary>
|
||||
/// Item dictionary file name
|
||||
/// </summary>
|
||||
public string ItemDictionaryFileName
|
||||
public string? ItemDictionaryFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(itemDictionaryFileName))
|
||||
if (string.IsNullOrEmpty(itemDictionaryFileName))
|
||||
itemDictionaryFileName = Path.Combine(PathTool.GetRuntimeDirectory(), $"itemDictionary{Guid.NewGuid()}.sqlite");
|
||||
|
||||
return itemDictionaryFileName;
|
||||
@@ -622,8 +624,8 @@ namespace SabreTools.DatFiles
|
||||
DiskCount++;
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count += (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -651,10 +653,10 @@ namespace SabreTools.DatFiles
|
||||
break;
|
||||
case Media media:
|
||||
MediaCount++;
|
||||
MD5Count += (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(media.SpamSum) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrEmpty(media.SpamSum) ? 0 : 1);
|
||||
break;
|
||||
case Part:
|
||||
PartCount++;
|
||||
@@ -679,13 +681,13 @@ namespace SabreTools.DatFiles
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize += rom.Size ?? 0;
|
||||
CRCCount += (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrWhiteSpace(rom.SpamSum) ? 0 : 1);
|
||||
CRCCount += (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
||||
MD5Count += (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
||||
SHA1Count += (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count += (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count += (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count += (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
|
||||
SpamSumCount += (string.IsNullOrEmpty(rom.SpamSum) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount += (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -1025,8 +1027,8 @@ namespace SabreTools.DatFiles
|
||||
DiskCount--;
|
||||
if (disk.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(disk.SHA1) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(disk.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(disk.SHA1) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (disk.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -1054,9 +1056,9 @@ namespace SabreTools.DatFiles
|
||||
break;
|
||||
case Media media:
|
||||
MediaCount--;
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(media.SHA256) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(media.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(media.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrEmpty(media.SHA256) ? 0 : 1);
|
||||
break;
|
||||
case Part:
|
||||
PartCount--;
|
||||
@@ -1078,12 +1080,12 @@ namespace SabreTools.DatFiles
|
||||
if (rom.ItemStatus != ItemStatus.Nodump)
|
||||
{
|
||||
TotalSize -= rom.Size ?? 0;
|
||||
CRCCount -= (string.IsNullOrWhiteSpace(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrWhiteSpace(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrWhiteSpace(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrWhiteSpace(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrWhiteSpace(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrWhiteSpace(rom.SHA512) ? 0 : 1);
|
||||
CRCCount -= (string.IsNullOrEmpty(rom.CRC) ? 0 : 1);
|
||||
MD5Count -= (string.IsNullOrEmpty(rom.MD5) ? 0 : 1);
|
||||
SHA1Count -= (string.IsNullOrEmpty(rom.SHA1) ? 0 : 1);
|
||||
SHA256Count -= (string.IsNullOrEmpty(rom.SHA256) ? 0 : 1);
|
||||
SHA384Count -= (string.IsNullOrEmpty(rom.SHA384) ? 0 : 1);
|
||||
SHA512Count -= (string.IsNullOrEmpty(rom.SHA512) ? 0 : 1);
|
||||
}
|
||||
|
||||
BaddumpCount -= (rom.ItemStatus == ItemStatus.BadDump ? 1 : 0);
|
||||
@@ -1135,7 +1137,7 @@ namespace SabreTools.DatFiles
|
||||
protected void EnsureDatabase()
|
||||
{
|
||||
// Make sure the file exists
|
||||
if (!System.IO.File.Exists(ItemDictionaryFileName))
|
||||
if (ItemDictionaryFileName != null && !System.IO.File.Exists(ItemDictionaryFileName))
|
||||
System.IO.File.Create(ItemDictionaryFileName);
|
||||
|
||||
// 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
|
||||
List<string> oldkeys = Keys.ToList();
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (this[key] == null)
|
||||
@@ -1225,7 +1233,11 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
// If the key is now empty, remove it
|
||||
if (this[key]!.Count == 0)
|
||||
Remove(key);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
||||
List<string> keys = Keys.ToList();
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
ConcurrentList<DatItem>? sortedlist = this[key]?.ToConcurrentList();
|
||||
@@ -1264,7 +1282,13 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
else
|
||||
{
|
||||
List<string> keys = Keys.ToList();
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
ConcurrentList<DatItem>? sortedlist = this[key];
|
||||
@@ -1530,3 +1554,5 @@ CREATE TABLE IF NOT EXISTS groups (
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<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>
|
||||
<Nullable>enable</Nullable>
|
||||
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||
<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>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -14,8 +27,12 @@
|
||||
<ProjectReference Include="..\SabreTools.Logging\SabreTools.Logging.csproj" />
|
||||
</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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SabreTools.IO" Version="1.3.0" />
|
||||
<PackageReference Include="SabreTools.Models" Version="1.3.0" />
|
||||
|
||||
@@ -33,7 +33,13 @@ namespace SabreTools.DatTools
|
||||
public static void ApplySuperDAT(DatFile datFile, List<ParentablePath> inputs)
|
||||
{
|
||||
List<string> keys = [.. datFile.Items.Keys];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (items == null)
|
||||
@@ -98,7 +104,13 @@ namespace SabreTools.DatTools
|
||||
intDat.Items.BucketBy(ItemKey.CRC, DedupeType.None);
|
||||
|
||||
// Then we do a hashwise comparison against the base DAT
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (datItems == null)
|
||||
@@ -136,7 +148,13 @@ namespace SabreTools.DatTools
|
||||
intDat.Items.BucketBy(ItemKey.Machine, DedupeType.None);
|
||||
|
||||
// Then we do a namewise comparison against the base DAT
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (datItems == null)
|
||||
@@ -194,7 +212,13 @@ namespace SabreTools.DatTools
|
||||
|
||||
// Then we compare against the base DAT
|
||||
List<string> keys = [.. intDat.Items.Keys];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
if (useGames)
|
||||
@@ -274,13 +298,23 @@ namespace SabreTools.DatTools
|
||||
|
||||
// Create the DatFiles from the set of headers
|
||||
DatFile[] outDatsArray = new DatFile[datHeaders.Count];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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]);
|
||||
diffData.Items = [];
|
||||
FillWithSourceIndex(datFile, diffData, j);
|
||||
outDatsArray[j] = diffData;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
outDats = [.. outDatsArray];
|
||||
watch.Stop();
|
||||
@@ -330,7 +364,13 @@ namespace SabreTools.DatTools
|
||||
// Now, loop through the dictionary and populate the correct DATs
|
||||
watch.Start("Populating duplicate DAT");
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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]);
|
||||
|
||||
@@ -341,7 +381,11 @@ namespace SabreTools.DatTools
|
||||
// Loop through and add the items correctly
|
||||
foreach (DatItem item in items)
|
||||
{
|
||||
#if NETFRAMEWORK
|
||||
if ((item.DupeType & DupeType.External) != 0)
|
||||
#else
|
||||
if (item.DupeType.HasFlag(DupeType.External))
|
||||
#endif
|
||||
{
|
||||
if (item.Clone() is not DatItem newrom)
|
||||
continue;
|
||||
@@ -396,7 +440,13 @@ namespace SabreTools.DatTools
|
||||
// Loop through each of the inputs and get or create a new DatData object
|
||||
DatFile[] outDatsArray = new DatFile[inputs.Count];
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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)";
|
||||
DatFile diffData = DatFile.Create(datFile.Header);
|
||||
@@ -405,7 +455,11 @@ namespace SabreTools.DatTools
|
||||
diffData.Header.Description += innerpost;
|
||||
diffData.Items = [];
|
||||
outDatsArray[j] = diffData;
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create a list of DatData objects representing individual output files
|
||||
List<DatFile> outDats = [.. outDatsArray];
|
||||
@@ -415,7 +469,13 @@ namespace SabreTools.DatTools
|
||||
// Now, loop through the dictionary and populate the correct DATs
|
||||
watch.Start("Populating all individual DATs");
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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]);
|
||||
|
||||
@@ -429,7 +489,11 @@ namespace SabreTools.DatTools
|
||||
if (item.Source == null)
|
||||
continue;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((item.DupeType & DupeType.Internal) != 0 || item.DupeType == 0x00)
|
||||
#else
|
||||
if (item.DupeType.HasFlag(DupeType.Internal) || item.DupeType == 0x00)
|
||||
#endif
|
||||
outDats[item.Source.Index].Items.Add(key, item);
|
||||
}
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
@@ -485,7 +549,13 @@ namespace SabreTools.DatTools
|
||||
// Now, loop through the dictionary and populate the correct DATs
|
||||
watch.Start("Populating no duplicate DAT");
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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]);
|
||||
|
||||
@@ -496,7 +566,11 @@ namespace SabreTools.DatTools
|
||||
// Loop through and add the items correctly
|
||||
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)
|
||||
#endif
|
||||
{
|
||||
if (item.Clone() is not DatItem newrom || newrom.Source == null)
|
||||
continue;
|
||||
@@ -540,13 +614,23 @@ namespace SabreTools.DatTools
|
||||
InternalStopwatch watch = new("Processing individual DATs");
|
||||
|
||||
// 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 =>
|
||||
#elif NET40_OR_GREATER
|
||||
Parallel.For(0, inputs.Count, i =>
|
||||
#else
|
||||
for (int i = 0; i < inputs.Count; i++)
|
||||
#endif
|
||||
{
|
||||
var input = inputs[i];
|
||||
logger.User($"Adding DAT: {input.CurrentPath}");
|
||||
datFiles[i] = DatFile.Create(datFile.Header.CloneFiltering());
|
||||
Parser.ParseInto(datFiles[i], input, i, keep: true);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
watch.Stop();
|
||||
|
||||
@@ -560,7 +644,7 @@ namespace SabreTools.DatTools
|
||||
|
||||
return datFiles.Select(d => d.Header).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Add items from another DatFile to the existing DatFile
|
||||
/// </summary>
|
||||
@@ -596,7 +680,13 @@ namespace SabreTools.DatTools
|
||||
private static void FillWithSourceIndex(DatFile datFile, DatFile indexDat, int index)
|
||||
{
|
||||
// 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 =>
|
||||
#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]);
|
||||
|
||||
|
||||
@@ -61,7 +61,13 @@ namespace SabreTools.DatTools
|
||||
List<string> files = Directory.EnumerateFiles(basePath, "*", SearchOption.AllDirectories).ToList();
|
||||
|
||||
// Loop through and add the file sizes
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
@@ -132,7 +138,11 @@ namespace SabreTools.DatTools
|
||||
archive.AvailableHashes = hashes;
|
||||
|
||||
// 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)
|
||||
#endif
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -144,7 +154,11 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
// 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))
|
||||
#endif
|
||||
{
|
||||
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);
|
||||
|
||||
// First take care of the found items
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
if (datItem == null)
|
||||
@@ -256,7 +276,13 @@ namespace SabreTools.DatTools
|
||||
empties = archive.GetEmptyFolders();
|
||||
|
||||
// Add add all of the found empties to the DAT
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
ProcessFileHelper(datFile, item, emptyRom, basePath, parent);
|
||||
@@ -279,7 +305,13 @@ namespace SabreTools.DatTools
|
||||
return;
|
||||
|
||||
List<string> empties = basePath.ListEmpty() ?? [];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
string fulldir = Path.GetFullPath(dir);
|
||||
|
||||
@@ -76,7 +76,13 @@ namespace SabreTools.DatTools
|
||||
|
||||
// Now loop through and get only directories from the input paths
|
||||
List<string> directories = [];
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
if (Directory.Exists(input))
|
||||
@@ -316,9 +322,17 @@ namespace SabreTools.DatTools
|
||||
DatItem? internalDatItem;
|
||||
if (internalFileInfo == 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))
|
||||
#endif
|
||||
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))
|
||||
#endif
|
||||
internalDatItem = new Disk(internalFileInfo);
|
||||
else
|
||||
internalDatItem = new Rom(internalFileInfo);
|
||||
@@ -713,7 +727,7 @@ namespace SabreTools.DatTools
|
||||
|
||||
return outputArchive;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get string value from input OutputFormat
|
||||
/// </summary>
|
||||
|
||||
@@ -63,7 +63,13 @@ namespace SabreTools.DatTools
|
||||
extBDat.Header.Description += $" ({newExtBString})";
|
||||
|
||||
// Now separate the roms accordingly
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (items == null)
|
||||
@@ -151,7 +157,13 @@ namespace SabreTools.DatTools
|
||||
fieldDats[DatItemField.NULL].Header.Description += " (Other)";
|
||||
|
||||
// Now populate each of the DAT objects in turn
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (items == null)
|
||||
@@ -250,7 +262,13 @@ namespace SabreTools.DatTools
|
||||
keys.Sort(SplitByLevelSort);
|
||||
|
||||
// Then, we loop over the games
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
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})";
|
||||
|
||||
// Now populate each of the DAT objects in turn
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
if (items == null)
|
||||
@@ -510,7 +534,13 @@ namespace SabreTools.DatTools
|
||||
}
|
||||
|
||||
// Now populate each of the DAT objects in turn
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
@@ -533,7 +563,13 @@ namespace SabreTools.DatTools
|
||||
private static void FillWithItemType(DatFile datFile, DatFile indexDat, ItemType itemType)
|
||||
{
|
||||
// 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 =>
|
||||
#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]);
|
||||
|
||||
|
||||
@@ -171,7 +171,13 @@ namespace SabreTools.DatTools
|
||||
try
|
||||
{
|
||||
// Write out all required formats
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
try
|
||||
@@ -223,19 +229,39 @@ namespace SabreTools.DatTools
|
||||
// For each output format, get the appropriate stream writer
|
||||
output.Add(StatReportFormat.None, CreateOutStatsNamesHelper(outDir, ".null", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((statDatFormat & StatReportFormat.Textfile) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.Textfile))
|
||||
#endif
|
||||
output.Add(StatReportFormat.Textfile, CreateOutStatsNamesHelper(outDir, ".txt", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((statDatFormat & StatReportFormat.CSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.CSV))
|
||||
#endif
|
||||
output.Add(StatReportFormat.CSV, CreateOutStatsNamesHelper(outDir, ".csv", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((statDatFormat & StatReportFormat.HTML) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.HTML))
|
||||
#endif
|
||||
output.Add(StatReportFormat.HTML, CreateOutStatsNamesHelper(outDir, ".html", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((statDatFormat & StatReportFormat.SSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.SSV))
|
||||
#endif
|
||||
output.Add(StatReportFormat.SSV, CreateOutStatsNamesHelper(outDir, ".ssv", reportName, overwrite));
|
||||
|
||||
#if NETFRAMEWORK
|
||||
if ((statDatFormat & StatReportFormat.TSV) != 0)
|
||||
#else
|
||||
if (statDatFormat.HasFlag(StatReportFormat.TSV))
|
||||
#endif
|
||||
output.Add(StatReportFormat.TSV, CreateOutStatsNamesHelper(outDir, ".tsv", reportName, overwrite));
|
||||
|
||||
return output;
|
||||
|
||||
@@ -78,8 +78,13 @@ namespace SabreTools.DatTools
|
||||
try
|
||||
{
|
||||
// Write out all required formats
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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];
|
||||
try
|
||||
@@ -122,7 +127,7 @@ namespace SabreTools.DatTools
|
||||
|
||||
var statsList = new List<DatStatistics>
|
||||
{
|
||||
new()
|
||||
new()
|
||||
{
|
||||
Statistics = datFile.Items,
|
||||
DisplayName = datFile.Header.FileName,
|
||||
@@ -189,6 +194,6 @@ namespace SabreTools.DatTools
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,11 @@ namespace SabreTools.Filtering
|
||||
return null;
|
||||
|
||||
// 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)!))
|
||||
#endif
|
||||
return true;
|
||||
|
||||
return single.Equals(value);
|
||||
|
||||
@@ -290,7 +290,11 @@ namespace SabreTools.Filtering
|
||||
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)))
|
||||
#endif
|
||||
continue;
|
||||
|
||||
// Get all device reference names from the current machine
|
||||
@@ -589,8 +593,13 @@ namespace SabreTools.Filtering
|
||||
continue;
|
||||
|
||||
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.Device)))
|
||||
#endif
|
||||
{
|
||||
datFile.Items.Remove(game);
|
||||
}
|
||||
@@ -614,7 +623,11 @@ namespace SabreTools.Filtering
|
||||
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))
|
||||
#endif
|
||||
continue;
|
||||
|
||||
// Determine if the game has a parent or not
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace SabreTools.Features
|
||||
|
||||
// Common Features
|
||||
AddCommonFeatures();
|
||||
|
||||
|
||||
AddFeature(OutputTypeListInput);
|
||||
this[OutputTypeListInput].AddFeature(DeprecatedFlag);
|
||||
AddFeature(OutputDirStringInput);
|
||||
@@ -94,7 +94,13 @@ namespace SabreTools.Features
|
||||
InternalStopwatch watch = new("Outputting hash-split DATs");
|
||||
|
||||
// Loop through each type DatFile
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
@@ -140,7 +146,13 @@ namespace SabreTools.Features
|
||||
InternalStopwatch watch = new("Outputting total-size-split DATs");
|
||||
|
||||
// Loop through each type DatFile
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
@@ -160,7 +172,13 @@ namespace SabreTools.Features
|
||||
InternalStopwatch watch = new("Outputting ItemType DATs");
|
||||
|
||||
// Loop through each type DatFile
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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);
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
|
||||
@@ -153,7 +153,13 @@ namespace SabreTools.Features
|
||||
if (updateMode == UpdateMode.None)
|
||||
{
|
||||
// Loop through each input and update
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
DatFile datFile = DatFile.Create(Header);
|
||||
@@ -242,13 +248,23 @@ namespace SabreTools.Features
|
||||
// Loop through and output the new DatFiles
|
||||
InternalStopwatch watch = new("Outputting all individual DATs");
|
||||
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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));
|
||||
|
||||
// Try to output the file
|
||||
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
watch.Stop();
|
||||
}
|
||||
@@ -257,7 +273,13 @@ namespace SabreTools.Features
|
||||
if (updateMode.HasFlag(UpdateMode.DiffCascade))
|
||||
{
|
||||
// Preprocess the DatHeaders
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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 (!GetBoolean(features, InplaceValue) && OutputDir == Environment.CurrentDirectory)
|
||||
@@ -269,7 +291,11 @@ namespace SabreTools.Features
|
||||
datHeaders[j].Name += innerpost;
|
||||
datHeaders[j].Description += innerpost;
|
||||
}
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get all of the output DatFiles
|
||||
List<DatFile> datFiles = DatFileTool.DiffCascade(userInputDat, datHeaders);
|
||||
@@ -278,13 +304,23 @@ namespace SabreTools.Features
|
||||
InternalStopwatch watch = new("Outputting all created DATs");
|
||||
|
||||
int startIndex = GetBoolean(features, SkipFirstOutputValue) ? 1 : 0;
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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));
|
||||
|
||||
// Try to output the file
|
||||
Writer.Write(datFiles[j], path, overwrite: GetBoolean(features, InplaceValue));
|
||||
#if NET40_OR_GREATER || NETCOREAPP
|
||||
});
|
||||
#else
|
||||
}
|
||||
#endif
|
||||
|
||||
watch.Stop();
|
||||
}
|
||||
@@ -293,7 +329,13 @@ namespace SabreTools.Features
|
||||
if (updateMode.HasFlag(UpdateMode.DiffAgainst))
|
||||
{
|
||||
// Loop through each input and diff against the base
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
DatFile repDat = DatFile.Create(Header);
|
||||
@@ -323,7 +365,13 @@ namespace SabreTools.Features
|
||||
if (updateMode.HasFlag(UpdateMode.BaseReplace))
|
||||
{
|
||||
// Loop through each input and apply the base DatFile
|
||||
#if NET452_OR_GREATER || NETCOREAPP
|
||||
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
|
||||
DatFile repDat = DatFile.Create(Header);
|
||||
|
||||
Reference in New Issue
Block a user