Fix build

This commit is contained in:
Matt Nadareski
2024-11-12 23:29:53 -05:00
parent 1e3aac6748
commit efe144313b
3 changed files with 5 additions and 29 deletions

View File

@@ -162,7 +162,7 @@ namespace BinaryObjectScanner.FileType
filename = Path.Combine(filename, parentNames[i]);
}
#else
filename = Path.Combine(parentNames);
filename = Path.Combine([.. parentNames]);
#endif
// Get the file offset

View File

@@ -73,13 +73,10 @@ namespace BinaryObjectScanner.Protection
return null;
int position = positions[0];
#if NET20 || NET35 || NET40
byte[] versionBytes = new byte[8];
Array.Copy(fileContent, position + 67, versionBytes, 0, 8);
char[] version = Array.ConvertAll(versionBytes, b => (char)b);
#else
char[] version = new ArraySegment<byte>(fileContent, position + 67, 8).Select(b => (char)b).ToArray();
#endif
return new string(version);
}
}

View File

@@ -168,7 +168,7 @@ namespace BinaryObjectScanner.Protection
if (versionTwo)
{
int index = position + 14;
#if NET20 || NET35 || NET40
byte[] temp = new byte[2];
Array.Copy(sectionContent, index, temp, 0, 2);
day = new string(Array.ConvertAll(temp, b => (char)b));
@@ -178,18 +178,11 @@ namespace BinaryObjectScanner.Protection
index += 3;
Array.Copy(sectionContent, index, temp, 0, 2);
year = "20" + new string(Array.ConvertAll(temp, b => (char)b));
#else
day = new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
month = new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
year = "20" + new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
#endif
}
else
{
int index = position + 13;
#if NET20 || NET35 || NET40
byte[] temp = new byte[2];
Array.Copy(sectionContent, index, temp, 0, 2);
day = new string(Array.ConvertAll(temp, b => (char)b));
@@ -199,13 +192,6 @@ namespace BinaryObjectScanner.Protection
index += 3;
Array.Copy(sectionContent, index, temp, 0, 2);
year = "20" + new string(Array.ConvertAll(temp, b => (char)b));
#else
day = new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
month = new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
index += 3;
year = "20" + new string(new ArraySegment<byte>(sectionContent, index, 2).Select(b => (char)b).ToArray());
#endif
}
return $"(Build {year}-{month}-{day})";
@@ -217,13 +203,9 @@ namespace BinaryObjectScanner.Protection
if (sectionContent == null)
return null;
#if NET20 || NET35 || NET40
byte[] temp = new byte[4];
Array.Copy(sectionContent, position + 76, temp, 0, 4);
return new string(Array.ConvertAll(temp, b => (char)b));
#else
return new string(new ArraySegment<byte>(sectionContent, position + 76, 4).Select(b => (char)b).ToArray());
#endif
}
public static string? GetVersion16Bit(string firstMatchedString, IEnumerable<string>? files)
@@ -238,13 +220,10 @@ namespace BinaryObjectScanner.Protection
private static string GetVersion16Bit(byte[] fileContent)
{
#if NET20 || NET35 || NET40
byte[] temp = new byte[7];
Array.Copy(fileContent, 71, temp, 0, 7);
char[] version = Array.ConvertAll(temp, b => (char)b);
#else
char[] version = new ArraySegment<byte>(fileContent, 71, 7).Select(b => (char)b).ToArray();
#endif
if (char.IsNumber(version[0]) && char.IsNumber(version[2]) && char.IsNumber(version[3]))
{
if (char.IsNumber(version[5]) && char.IsNumber(version[6]))