/** @return null if the file was extracted and loaded. */ private Throwable loadFile (String sourcePath, String sourceCrc, File extractedFile) { try { System.load(extractFile(sourcePath, sourceCrc, extractedFile).getAbsolutePath()); return null; } catch (Throwable ex) { return ex; } }
/** Extracts the LWJGL native libraries from the classpath and sets the "org.lwjgl.librarypath" system property. */ static public void load () { GdxNativesLoader.load(); if (GdxNativesLoader.disableNativesLoading) return; if (!load) return; SharedLibraryLoader loader = new SharedLibraryLoader(); File nativesDir = null; try { if (isWindows) { nativesDir = loader.extractFile(is64Bit ? "lwjgl64.dll" : "lwjgl.dll", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "OpenAL64.dll" : "OpenAL32.dll", nativesDir); } else if (isMac) { nativesDir = loader.extractFile("liblwjgl.dylib", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo("openal.dylib", nativesDir); } else if (isLinux) { nativesDir = loader.extractFile(is64Bit ? "liblwjgl64.so" : "liblwjgl.so", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "libopenal64.so" : "libopenal.so", nativesDir); } } catch (Throwable ex) { throw new GdxRuntimeException("Unable to extract LWJGL natives.", ex); } System.setProperty("org.lwjgl.librarypath", nativesDir.getAbsolutePath()); load = false; } }
/** @return null if the file was extracted and loaded. */ private Throwable loadFile (String sourcePath, String sourceCrc, File extractedFile) { try { System.load(extractFile(sourcePath, sourceCrc, extractedFile).getAbsolutePath()); return null; } catch (Throwable ex) { return ex; } }
/** Extracts the LWJGL native libraries from the classpath and sets the "org.lwjgl.librarypath" system property. */ static public void load () { GdxNativesLoader.load(); if (GdxNativesLoader.disableNativesLoading) return; if (!load) return; SharedLibraryLoader loader = new SharedLibraryLoader(); File nativesDir = null; try { if (isWindows) { nativesDir = loader.extractFile(is64Bit ? "lwjgl64.dll" : "lwjgl.dll", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "OpenAL64.dll" : "OpenAL32.dll", nativesDir); } else if (isMac) { nativesDir = loader.extractFile("liblwjgl.dylib", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo("openal.dylib", nativesDir); } else if (isLinux) { nativesDir = loader.extractFile(is64Bit ? "liblwjgl64.so" : "liblwjgl.so", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "libopenal64.so" : "libopenal.so", nativesDir); } } catch (Throwable ex) { throw new GdxRuntimeException("Unable to extract LWJGL natives.", ex); } System.setProperty("org.lwjgl.librarypath", nativesDir.getAbsolutePath()); load = false; } }
/** 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dir The location where the extracted file will be written. */ public void extractFileTo (String sourcePath, File dir) throws IOException { extractFile(sourcePath, crc(readFile(sourcePath)), new File(dir, new File(sourcePath).getName())); }
/** Extracts the LWJGL native libraries from the classpath and sets the "org.lwjgl.librarypath" system property. */ static public void load () { GdxNativesLoader.load(); if (GdxNativesLoader.disableNativesLoading) return; if (!load) return; SharedLibraryLoader loader = new SharedLibraryLoader(); File nativesDir = null; try { if (isWindows) { nativesDir = loader.extractFile(is64Bit ? "lwjgl64.dll" : "lwjgl.dll", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "OpenAL64.dll" : "OpenAL32.dll", nativesDir); } else if (isMac) { nativesDir = loader.extractFile("liblwjgl.dylib", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo("openal.dylib", nativesDir); } else if (isLinux) { nativesDir = loader.extractFile(is64Bit ? "liblwjgl64.so" : "liblwjgl.so", null).getParentFile(); if (!LwjglApplicationConfiguration.disableAudio) loader.extractFileTo(is64Bit ? "libopenal64.so" : "libopenal.so", nativesDir); } } catch (Throwable ex) { throw new GdxRuntimeException("Unable to extract LWJGL natives.", ex); } System.setProperty("org.lwjgl.librarypath", nativesDir.getAbsolutePath()); load = false; } }
/** 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dir The location where the extracted file will be written. */ public void extractFileTo (String sourcePath, File dir) throws IOException { extractFile(sourcePath, crc(readFile(sourcePath)), new File(dir, new File(sourcePath).getName())); }
/** Extracts the specified file to the specified 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dirName The name of the subdirectory where the file will be extracted. If null, the file's CRC will be used. * @return The extracted file. */ public File extractFile (String sourcePath, String dirName) throws IOException { try { String sourceCrc = crc(readFile(sourcePath)); if (dirName == null) dirName = sourceCrc; File extractedFile = getExtractedFile(dirName, new File(sourcePath).getName()); if (extractedFile == null) { extractedFile = getExtractedFile(UUID.randomUUID().toString(), new File(sourcePath).getName()); if (extractedFile == null) throw new GdxRuntimeException( "Unable to find writable path to extract file. Is the user home directory writable?"); } return extractFile(sourcePath, sourceCrc, extractedFile); } catch (RuntimeException ex) { // Fallback to file at java.library.path location, eg for applets. File file = new File(System.getProperty("java.library.path"), sourcePath); if (file.exists()) return file; throw ex; } }
/** Extracts the specified file to the specified 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dirName The name of the subdirectory where the file will be extracted. If null, the file's CRC will be used. * @return The extracted file. */ public File extractFile (String sourcePath, String dirName) throws IOException { try { String sourceCrc = crc(readFile(sourcePath)); if (dirName == null) dirName = sourceCrc; File extractedFile = getExtractedFile(dirName, new File(sourcePath).getName()); if (extractedFile == null) { extractedFile = getExtractedFile(UUID.randomUUID().toString(), new File(sourcePath).getName()); if (extractedFile == null) throw new GdxRuntimeException( "Unable to find writable path to extract file. Is the user home directory writable?"); } return extractFile(sourcePath, sourceCrc, extractedFile); } catch (RuntimeException ex) { // Fallback to file at java.library.path location, eg for applets. File file = new File(System.getProperty("java.library.path"), sourcePath); if (file.exists()) return file; throw ex; } }
/** @return null if the file was extracted and loaded. */ private Throwable loadFile (String sourcePath, String sourceCrc, File extractedFile) { try { System.load(extractFile(sourcePath, sourceCrc, extractedFile).getAbsolutePath()); return null; } catch (Throwable ex) { return ex; } }
/** 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dir The location where the extracted file will be written. */ public void extractFileTo (String sourcePath, File dir) throws IOException { extractFile(sourcePath, crc(readFile(sourcePath)), new File(dir, new File(sourcePath).getName())); }
/** Extracts the specified file to the specified 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. * @param sourcePath The file to extract from the classpath or JAR. * @param dirName The name of the subdirectory where the file will be extracted. If null, the file's CRC will be used. * @return The extracted file. */ public File extractFile (String sourcePath, String dirName) throws IOException { try { String sourceCrc = crc(readFile(sourcePath)); if (dirName == null) dirName = sourceCrc; File extractedFile = getExtractedFile(dirName, new File(sourcePath).getName()); if (extractedFile == null) { extractedFile = getExtractedFile(UUID.randomUUID().toString(), new File(sourcePath).getName()); if (extractedFile == null) throw new GdxRuntimeException( "Unable to find writable path to extract file. Is the user home directory writable?"); } return extractFile(sourcePath, sourceCrc, extractedFile); } catch (RuntimeException ex) { // Fallback to file at java.library.path location, eg for applets. File file = new File(System.getProperty("java.library.path"), sourcePath); if (file.exists()) return file; throw ex; } }