Class ZstdNativesLoader
java.lang.Object
dev.freya02.discord.zstd.api.ZstdNativesLoader
Utility class to load Zstd natives.
An alternative to load natives is to set the zstd.lib system property
to the absolute path of the native library.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisLoaded()Whether natives were already loaded.static booleanLoads the natives from the provided path's file.static booleanLoads the natives from this library's JAR.static booleanloadFromJar(String resourcePath, Class<?> clazz) Loads the natives using the provided path from the provided class.
-
Constructor Details
-
ZstdNativesLoader
public ZstdNativesLoader()
-
-
Method Details
-
isLoaded
public static boolean isLoaded()Whether natives were already loaded. This only considers natives loaded by this class.- Returns:
trueif natives are loaded
-
load
Loads the natives from the provided path's file.- Parameters:
path- The path to the native library- Returns:
trueif the natives were loaded,falseif they already were- Throws:
IllegalArgumentException- Ifpathisnull
-
loadFromJar
Loads the natives from this library's JAR.- Returns:
trueif the natives were loaded,falseif they already were- Throws:
UnsupportedOperationException- If the current platform (OS + architecture) is not supported by defaultIOException- When the native extraction fails
-
loadFromJar
Loads the natives using the provided path from the provided class.Remember the resource path is relative to the provided class, unless prefixed with
/.- Parameters:
resourcePath- The path to the native library in the provided classclazz- The class from which to relatively load the resource from- Returns:
trueif the natives were loaded,falseif they already were- Throws:
IllegalArgumentException- IfresourcePathorclazzisnullIOException- If the resource does not exist or when extracting it fails
-