Skip to content

Commit

Permalink
Add ability to specify the Zstd temp folder with a property
Browse files Browse the repository at this point in the history
The new property is `ZstdTempFolder` and it is used to extract the
native library and load it from there.

Addresses: #315
  • Loading branch information
luben committed Jun 19, 2024
1 parent 0f657c0 commit c057b94
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/github/luben/zstd/util/Native.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public enum Native {
;

private static final String nativePathOverride = "ZstdNativePath";
private static final String tempFolderOverride = "ZstdTempFolder";
private static final String libnameShort = "zstd-jni-" + ZstdVersion.VERSION;
private static final String libname = "lib" + libnameShort;
private static final String errorMsg = "Unsupported OS/arch, cannot find " +
Expand Down Expand Up @@ -83,7 +84,12 @@ public Void run() {
}

public static synchronized void load() {
load(null);
String tempFolder = System.getProperty(tempFolderOverride);
if (tempFolder == null) {
load(null);
} else {
load(new File(tempFolder));
}
}

public static synchronized void load(final File tempFolder) {
Expand Down

0 comments on commit c057b94

Please sign in to comment.