* Native extraction will place natives in working directory unless its non-writable, in that case it will place them in <home dir>/.jme3/natives_<apphash>
* Hopefully fixed NPE in computing extraction hash git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8486 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
dfafd24ab8
commit
164dec188a
@ -63,11 +63,17 @@ public class Natives {
|
|||||||
return extractionDirOverride;
|
return extractionDirOverride;
|
||||||
}
|
}
|
||||||
if (extractionDir == null) {
|
if (extractionDir == null) {
|
||||||
|
File workingFolder = new File("").getAbsoluteFile();
|
||||||
|
if (!workingFolder.canWrite()) {
|
||||||
|
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()));
|
||||||
if (!extractionDir.exists()) {
|
if (!extractionDir.exists()) {
|
||||||
extractionDir.mkdir();
|
extractionDir.mkdir();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
extractionDir = workingFolder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return extractionDir;
|
return extractionDir;
|
||||||
}
|
}
|
||||||
@ -75,8 +81,8 @@ public class Natives {
|
|||||||
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 = Natives.class.getResource("");
|
URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/Natives.class");
|
||||||
if (url != null) {
|
|
||||||
StringBuilder sb = new StringBuilder(url.toString());
|
StringBuilder sb = new StringBuilder(url.toString());
|
||||||
if (sb.indexOf("jar:") == 0) {
|
if (sb.indexOf("jar:") == 0) {
|
||||||
sb.delete(0, 4);
|
sb.delete(0, 4);
|
||||||
@ -88,7 +94,7 @@ public class Natives {
|
|||||||
} catch (MalformedURLException ex) {
|
} catch (MalformedURLException ex) {
|
||||||
throw new UnsupportedOperationException(ex);
|
throw new UnsupportedOperationException(ex);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user