* NativeLibraryLoader.loadNativeLibrary("mystuff", true);
- *
- * It will load the right library automatically based on the platform.
- *
+ * It will load the right library automatically based on the
+ * platform.
+ *
* @author Kirill Vainer
*/
public final class NativeLibraryLoader {
-
+
private static final Logger logger = Logger.getLogger(NativeLibraryLoader.class.getName());
private static final byte[] buf = new byte[1024 * 100];
private static File extractionFolderOverride = null;
private static File extractionFolder = null;
-
+
private static final HashMapnull
to restore default
+ * Specify a custom location where native libraries should be extracted to.
+ * Ensure this is a unique path not used by other applications to extract
+ * their libraries. Set to null
to restore default
* functionality.
- *
+ *
* @param path Path where to extract native libraries.
*/
public static void setCustomExtractionFolder(String path) {
- extractionFolderOverride = new File(path).getAbsoluteFile();
+ if (path != null) {
+ extractionFolderOverride = new File(path).getAbsoluteFile();
+ } else {
+ extractionFolderOverride = null;
+ }
}
/**
- * Returns the folder where native libraries will be extracted.
- * This is automatically determined at run-time based on the
- * following criteria:natives_<hash>
where <hash>
- * is computed automatically as the XOR of the classpath hash code
- * and the last modified date of this class.
- *
+ * natives_<hash>
where <hash> is computed
+ * automatically as the XOR of the classpath hash code and the last modified
+ * date of this class.
+ *
* @return Path where natives will be extracted to.
*/
public static File getExtractionFolder() {
@@ -268,27 +274,27 @@ public final class NativeLibraryLoader {
}
return extractionFolder;
}
-
+
/**
* Determine jME3's cache folder for the user account based on the OS.
- *
- * If the OS cache folder is missing, the assumption is that this
- * particular version of the OS does not have a dedicated cache folder,
- * hence, we use the user's home folder instead as the root.
- *
+ *
+ * If the OS cache folder is missing, the assumption is that this particular
+ * version of the OS does not have a dedicated cache folder, hence, we use
+ * the user's home folder instead as the root.
+ *
* The folder returned is as follows:
* E.g.
*