Support ancient .NET in DatFiles

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

View File

@@ -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