Skip to content

Instantly share code, notes, and snippets.

@rlm
Created November 30, 2011 05:20
Show Gist options
  • Save rlm/1408143 to your computer and use it in GitHub Desktop.
Save rlm/1408143 to your computer and use it in GitHub Desktop.
Index: src/desktop/com/jme3/system/Natives.java
===================================================================
--- src/desktop/com/jme3/system/Natives.java (revision 8731)
+++ src/desktop/com/jme3/system/Natives.java (working copy)
@@ -45,7 +45,6 @@
/**
* Helper class for extracting the natives (dll, so) from the jars.
- * This class should only be used internally.
*/
public class Natives {
@@ -114,15 +113,19 @@
}
}
- protected static void extractNativeLib(String sysName, String name) throws IOException {
+ public static void extractNativeLib(String sysName, String name) throws IOException {
extractNativeLib(sysName, name, false, true);
}
- protected static void extractNativeLib(String sysName, String name, boolean load) throws IOException {
+ public static void extractNativeLib(String sysName, String name, boolean load) throws IOException {
extractNativeLib(sysName, name, load, true);
}
- protected static void extractNativeLib(String sysName, String name, boolean load, boolean warning) throws IOException {
+
+ public static void extractNativeLib(String sysName, String name, boolean load, boolean warning) throws IOException{
+
String fullname = System.mapLibraryName(name);
String path = "native/" + sysName + "/" + fullname;
@@ -142,14 +145,15 @@
try {
if (targetFile.exists()) {
- // OK, compare last modified date of this file to
- // file in jar
+ // OK, compare last modified date and size of this file to file in jar.
long targetLastModified = targetFile.lastModified();
long sourceLastModified = conn.getLastModified();
-
+ long targetLength = targetFile.length();
+ long sourceLength = conn.getContentLength();
// Allow ~1 second range for OSes that only support low precision
- if (targetLastModified + 1000 > sourceLastModified) {
- logger.log(Level.FINE, "Not copying library {0}. Latest already extracted.", fullname);
+
+ if ((targetLength == sourceLength) && (targetLastModified + 1000 > sourceLastModified)) {
+ logger.log(Level.FINE, "Not copying library {0}. Latest already extracted.", fullname);
return;
}
}
@@ -182,7 +186,7 @@
protected static boolean isUsingNativeBullet() {
try {
- Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil");
+ Class<?> clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil");
return clazz != null;
} catch (ClassNotFoundException ex) {
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment