|
|
@ -58,13 +58,13 @@ public class Natives { |
|
|
|
extractionDirOverride = new File(name).getAbsoluteFile(); |
|
|
|
extractionDirOverride = new File(name).getAbsoluteFile(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static File getExtractionDir(){ |
|
|
|
public static File getExtractionDir() { |
|
|
|
if (extractionDirOverride != null) { |
|
|
|
if (extractionDirOverride != null) { |
|
|
|
return extractionDirOverride; |
|
|
|
return extractionDirOverride; |
|
|
|
} |
|
|
|
} |
|
|
|
if (extractionDir == null) { |
|
|
|
if (extractionDir == null) { |
|
|
|
File workingFolder = new File("").getAbsoluteFile(); |
|
|
|
File workingFolder = new File("").getAbsoluteFile(); |
|
|
|
if (workingFolder.getUsableSpace()>0) { |
|
|
|
if (workingFolder.getUsableSpace() == 0 || !workingFolder.canWrite()) { |
|
|
|
logger.log(Level.WARNING, "Working directory is not writable. Using home directory instead."); |
|
|
|
logger.log(Level.WARNING, "Working directory is not writable. Using home directory instead."); |
|
|
|
extractionDir = new File(JmeSystem.getStorageFolder(), |
|
|
|
extractionDir = new File(JmeSystem.getStorageFolder(), |
|
|
|
"natives_" + Integer.toHexString(computeNativesHash())); |
|
|
|
"natives_" + Integer.toHexString(computeNativesHash())); |
|
|
@ -78,7 +78,7 @@ public class Natives { |
|
|
|
return extractionDir; |
|
|
|
return extractionDir; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static int computeNativesHash(){ |
|
|
|
private static int computeNativesHash() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
String classpath = System.getProperty("java.class.path"); |
|
|
|
String classpath = System.getProperty("java.class.path"); |
|
|
|
URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/Natives.class"); |
|
|
|
URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/Natives.class"); |
|
|
@ -96,7 +96,7 @@ public class Natives { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
URLConnection conn = url.openConnection(); |
|
|
|
URLConnection conn = url.openConnection(); |
|
|
|
int hash = classpath.hashCode() ^ (int)conn.getLastModified(); |
|
|
|
int hash = classpath.hashCode() ^ (int) conn.getLastModified(); |
|
|
|
return hash; |
|
|
|
return hash; |
|
|
|
} catch (IOException ex) { |
|
|
|
} catch (IOException ex) { |
|
|
|
throw new UnsupportedOperationException(ex); |
|
|
|
throw new UnsupportedOperationException(ex); |
|
|
@ -130,14 +130,14 @@ public class Natives { |
|
|
|
File targetFile = new File(getExtractionDir(), fullname); |
|
|
|
File targetFile = new File(getExtractionDir(), fullname); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (targetFile.exists()){ |
|
|
|
if (targetFile.exists()) { |
|
|
|
// OK, compare last modified date of this file to
|
|
|
|
// OK, compare last modified date of this file to
|
|
|
|
// file in jar
|
|
|
|
// file in jar
|
|
|
|
long targetLastModified = targetFile.lastModified(); |
|
|
|
long targetLastModified = targetFile.lastModified(); |
|
|
|
long sourceLastModified = conn.getLastModified(); |
|
|
|
long sourceLastModified = conn.getLastModified(); |
|
|
|
|
|
|
|
|
|
|
|
// Allow ~1 second range for OSes that only support low precision
|
|
|
|
// Allow ~1 second range for OSes that only support low precision
|
|
|
|
if (targetLastModified + 1000 > sourceLastModified){ |
|
|
|
if (targetLastModified + 1000 > sourceLastModified) { |
|
|
|
logger.log(Level.FINE, "Not copying library {0}. Latest already extracted.", fullname); |
|
|
|
logger.log(Level.FINE, "Not copying library {0}. Latest already extracted.", fullname); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
@ -169,7 +169,7 @@ public class Natives { |
|
|
|
logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile}); |
|
|
|
logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static boolean isUsingNativeBullet(){ |
|
|
|
protected static boolean isUsingNativeBullet() { |
|
|
|
try { |
|
|
|
try { |
|
|
|
Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil"); |
|
|
|
Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil"); |
|
|
|
return clazz != null; |
|
|
|
return clazz != null; |
|
|
|