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

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