mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Support ancient .NET in Skippers
This commit is contained in:
@@ -53,7 +53,7 @@ namespace SabreTools.Skippers
|
|||||||
public Rule? GetMatchingRule(Stream input, string skipperName)
|
public Rule? GetMatchingRule(Stream input, string skipperName)
|
||||||
{
|
{
|
||||||
// If we have no name supplied, try to blindly match
|
// If we have no name supplied, try to blindly match
|
||||||
if (string.IsNullOrWhiteSpace(skipperName))
|
if (string.IsNullOrEmpty(skipperName))
|
||||||
return GetMatchingRule(input);
|
return GetMatchingRule(input);
|
||||||
|
|
||||||
// If the name matches the internal name of the skipper
|
// If the name matches the internal name of the skipper
|
||||||
|
|||||||
@@ -130,14 +130,14 @@ namespace SabreTools.Skippers
|
|||||||
public bool TransformFile(string input, string output)
|
public bool TransformFile(string input, string output)
|
||||||
{
|
{
|
||||||
// If the input file doesn't exist
|
// If the input file doesn't exist
|
||||||
if (string.IsNullOrWhiteSpace(input) || !File.Exists(input))
|
if (string.IsNullOrEmpty(input) || !File.Exists(input))
|
||||||
{
|
{
|
||||||
logger.Error($"'{input}' doesn't exist and cannot be transformed!");
|
logger.Error($"'{input}' doesn't exist and cannot be transformed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have an invalid output directory name
|
// If we have an invalid output directory name
|
||||||
if (string.IsNullOrWhiteSpace(output))
|
if (string.IsNullOrEmpty(output))
|
||||||
{
|
{
|
||||||
logger.Error($"Output path was null or empty, cannot write transformed file!");
|
logger.Error($"Output path was null or empty, cannot write transformed file!");
|
||||||
return false;
|
return false;
|
||||||
@@ -284,6 +284,7 @@ namespace SabreTools.Skippers
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
#if NET40_OR_GREATER
|
||||||
// If we're not keeping the read stream open, dispose of the binary reader
|
// If we're not keeping the read stream open, dispose of the binary reader
|
||||||
if (!keepReadOpen)
|
if (!keepReadOpen)
|
||||||
br?.Dispose();
|
br?.Dispose();
|
||||||
@@ -291,6 +292,7 @@ namespace SabreTools.Skippers
|
|||||||
// If we're not keeping the write stream open, dispose of the binary reader
|
// If we're not keeping the write stream open, dispose of the binary reader
|
||||||
if (!keepWriteOpen)
|
if (!keepWriteOpen)
|
||||||
bw?.Dispose();
|
bw?.Dispose();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
|
|||||||
@@ -1,10 +1,23 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
|
<!-- Assembly Properties -->
|
||||||
|
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
|
||||||
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
|
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Version>1.1.2</Version>
|
||||||
|
|
||||||
|
<!-- Package Properties -->
|
||||||
|
<Authors>Matt Nadareski</Authors>
|
||||||
|
<Copyright>Copyright (c)2016-2024 Matt Nadareski</Copyright>
|
||||||
|
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
|
||||||
|
<RepositoryUrl>https://github.com/SabreTools/SabreTools</RepositoryUrl>
|
||||||
|
<RepositoryType>git</RepositoryType>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -79,7 +79,11 @@ namespace SabreTools.Skippers
|
|||||||
var xts = new XmlSerializer(typeof(Detector));
|
var xts = new XmlSerializer(typeof(Detector));
|
||||||
|
|
||||||
// Get skippers for each known header type
|
// Get skippers for each known header type
|
||||||
|
#if NET20 || NET35
|
||||||
|
foreach (string skipperPath in Directory.GetFiles(LocalPath, "*"))
|
||||||
|
#else
|
||||||
foreach (string skipperPath in Directory.EnumerateFiles(LocalPath, "*", SearchOption.AllDirectories))
|
foreach (string skipperPath in Directory.EnumerateFiles(LocalPath, "*", SearchOption.AllDirectories))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -87,7 +91,9 @@ namespace SabreTools.Skippers
|
|||||||
var xtr = XmlReader.Create(skipperPath, new XmlReaderSettings
|
var xtr = XmlReader.Create(skipperPath, new XmlReaderSettings
|
||||||
{
|
{
|
||||||
CheckCharacters = false,
|
CheckCharacters = false,
|
||||||
|
#if NET40_OR_GREATER
|
||||||
DtdProcessing = DtdProcessing.Ignore,
|
DtdProcessing = DtdProcessing.Ignore,
|
||||||
|
#endif
|
||||||
IgnoreComments = true,
|
IgnoreComments = true,
|
||||||
IgnoreWhitespace = true,
|
IgnoreWhitespace = true,
|
||||||
ValidationFlags = XmlSchemaValidationFlags.None,
|
ValidationFlags = XmlSchemaValidationFlags.None,
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ namespace SabreTools.Skippers
|
|||||||
protected static byte[]? ParseByteArrayFromHex(string? hex)
|
protected static byte[]? ParseByteArrayFromHex(string? hex)
|
||||||
{
|
{
|
||||||
// If we have an invalid string
|
// If we have an invalid string
|
||||||
if (string.IsNullOrWhiteSpace(hex))
|
if (string.IsNullOrEmpty(hex))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var ret = new byte[hex.Length / 2];
|
var ret = new byte[hex!.Length / 2];
|
||||||
for (int index = 0; index < ret.Length; index++)
|
for (int index = 0; index < ret.Length; index++)
|
||||||
{
|
{
|
||||||
string byteValue = hex.Substring(index * 2, 2);
|
string byteValue = hex.Substring(index * 2, 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user