Class DiscordZstdNativesLoader

java.lang.Object
dev.freya02.discord.zstd.api.DiscordZstdNativesLoader

@NullMarked public class DiscordZstdNativesLoader extends Object
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 Details

    • DiscordZstdNativesLoader

      public DiscordZstdNativesLoader()
  • Method Details

    • isLoaded

      public static boolean isLoaded()
      Whether natives were already loaded. This only considers natives loaded by this class.
      Returns:
      true if natives are loaded
    • load

      public static boolean load(Path path)
      Loads the natives from the provided path's file.
      Parameters:
      path - The path to the native library
      Returns:
      true if the natives were loaded, false if they already were
      Throws:
      IllegalArgumentException - If path is null
    • loadFromJar

      public static boolean loadFromJar(String resourcePath, Class<?> clazz) throws IOException
      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 class
      clazz - The class from which to relatively load the resource from
      Returns:
      true if the natives were loaded, false if they already were
      Throws:
      IllegalArgumentException - If resourcePath or clazz is null
      IOException - If the resource does not exist or when extracting it fails