- change natives extraction to check for space *and* writability

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8515 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent 73fb54b4b6
commit 65cbed47c6
  1. 14
      engine/src/desktop/com/jme3/system/Natives.java

@ -58,13 +58,13 @@ public class Natives {
extractionDirOverride = new File(name).getAbsoluteFile();
}
public static File getExtractionDir(){
public static File getExtractionDir() {
if (extractionDirOverride != null) {
return extractionDirOverride;
}
if (extractionDir == null) {
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.");
extractionDir = new File(JmeSystem.getStorageFolder(),
"natives_" + Integer.toHexString(computeNativesHash()));
@ -78,7 +78,7 @@ public class Natives {
return extractionDir;
}
private static int computeNativesHash(){
private static int computeNativesHash() {
try {
String classpath = System.getProperty("java.class.path");
URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/Natives.class");
@ -96,7 +96,7 @@ public class Natives {
}
URLConnection conn = url.openConnection();
int hash = classpath.hashCode() ^ (int)conn.getLastModified();
int hash = classpath.hashCode() ^ (int) conn.getLastModified();
return hash;
} catch (IOException ex) {
throw new UnsupportedOperationException(ex);
@ -130,14 +130,14 @@ public class Natives {
File targetFile = new File(getExtractionDir(), fullname);
try {
if (targetFile.exists()){
if (targetFile.exists()) {
// OK, compare last modified date of this file to
// file in jar
long targetLastModified = targetFile.lastModified();
long sourceLastModified = conn.getLastModified();
// 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);
return;
}
@ -169,7 +169,7 @@ public class Natives {
logger.log(Level.FINE, "Copied {0} to {1}", new Object[]{fullname, targetFile});
}
protected static boolean isUsingNativeBullet(){
protected static boolean isUsingNativeBullet() {
try {
Class clazz = Class.forName("com.jme3.bullet.util.NativeMeshUtil");
return clazz != null;

Loading…
Cancel
Save