com.badlogic.gdx.utils
Class SharedLibraryLoader

java.lang.Object
  extended by com.badlogic.gdx.utils.SharedLibraryLoader

public class SharedLibraryLoader
extends Object

Loads shared libraries from a natives jar file (desktop) or arm folders (Android). For desktop projects, have the natives jar in the classpath, for Android projects put the shared libraries in the libs/armeabi and libs/armeabi-v7a folders.

Author:
mzechner, Nathan Sweet

Field Summary
static boolean is64Bit
           
static boolean isAndroid
           
static boolean isIos
           
static boolean isLinux
           
static boolean isMac
           
static boolean isWindows
           
 
Constructor Summary
SharedLibraryLoader()
           
SharedLibraryLoader(String nativesJar)
          Fetches the natives from the given natives jar file.
 
Method Summary
 String crc(InputStream input)
          Returns a CRC of the remaining bytes in the stream.
 File extractFile(String sourcePath, String dirName)
          Extracts the specified file into the temp directory if it does not already exist or the CRC does not match.
 void load(String libraryName)
          Loads a shared library for the platform the application is running on.
 String mapLibraryName(String libraryName)
          Maps a platform independent library name to a platform dependent name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isWindows

public static boolean isWindows

isLinux

public static boolean isLinux

isMac

public static boolean isMac

isIos

public static boolean isIos

isAndroid

public static boolean isAndroid

is64Bit

public static boolean is64Bit
Constructor Detail

SharedLibraryLoader

public SharedLibraryLoader()

SharedLibraryLoader

public SharedLibraryLoader(String nativesJar)
Fetches the natives from the given natives jar file. Used for testing a shared lib on the fly.

Parameters:
nativesJar -
Method Detail

crc

public String crc(InputStream input)
Returns a CRC of the remaining bytes in the stream.


mapLibraryName

public String mapLibraryName(String libraryName)
Maps a platform independent library name to a platform dependent name.


load

public void load(String libraryName)
Loads a shared library for the platform the application is running on.

Parameters:
libraryName - The platform independent library name. If not contain a prefix (eg lib) or suffix (eg .dll).

extractFile

public File extractFile(String sourcePath,
                        String dirName)
                 throws IOException
Extracts the specified file into the temp directory if it does not already exist or the CRC does not match. If file extraction fails and the file exists at java.library.path, that file is returned.

Parameters:
sourcePath - The file to extract from the classpath or JAR.
dirName - The name of the subdirectory where the file will be extracted. If null, the file's CRC will be used.
Returns:
The extracted file.
Throws:
IOException


Copyright © 2013. All Rights Reserved.