Skip to content

Commit 7d6cf9a

Browse files
committed
Add a static to ignore missing library
+ This will be used for ignoring dll check while static library on AOT build is preferred
1 parent 41fc5cc commit 7d6cf9a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

ZstdNet/ExternMethods.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,17 @@ public static void SetWinDllDirectory()
5555
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
5656
private static extern bool SetDllDirectory(string path);
5757
#else
58-
public static bool IsLibraryExist(string libraryName) => File.Exists(string.Format(_libFullPath, libraryName));
58+
public static bool IsIgnoreMissingLibrary = false;
59+
60+
public static bool IsLibraryExist(string libraryName) => IsIgnoreMissingLibrary || File.Exists(string.Format(_libFullPath, libraryName));
61+
62+
#if NET6_0_OR_GREATER
63+
public static void ThrowIfDllNotExist()
64+
{
65+
if (!IsLibraryExist(DllName))
66+
throw new DllNotFoundException("libzstd.dll is not found!");
67+
}
68+
#endif
5969

6070
internal static IntPtr DllImportResolver(string libraryName, Assembly assembly, DllImportSearchPath? searchPath)
6171
{

ZstdNet/ThrowHelper.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ namespace ZstdNet
77
internal static class ReturnValueExtensions
88
{
99
#if NET6_0_OR_GREATER
10-
public static void ThrowIfDllNotExist()
11-
{
12-
if (!DllUtils.IsLibraryExist(DllUtils.DllName))
13-
throw new DllNotFoundException("libzstd.dll is not found!");
14-
}
10+
public static void ThrowIfDllNotExist() => DllUtils.ThrowIfDllNotExist();
1511
#endif
1612

1713
public static size_t EnsureZdictSuccess(this size_t returnValue)

ZstdNet/ZstdNet.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<Version>1.6.3</Version>
3+
<Version>1.6.4</Version>
44
<TargetFrameworks>netstandard2.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
55
<Title>ZstdNet</Title>
66
<PackageId>Hi3Helper.ZstdNet</PackageId>

0 commit comments

Comments
 (0)