- add write test to natives extraction
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8518 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
dae6ef534b
commit
45af20de0c
@ -65,19 +65,30 @@ public class Natives {
|
||||
if (extractionDir == null) {
|
||||
File workingFolder = new File("").getAbsoluteFile();
|
||||
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()));
|
||||
if (!extractionDir.exists()) {
|
||||
extractionDir.mkdir();
|
||||
}
|
||||
setStorageExtractionDir();
|
||||
} else {
|
||||
extractionDir = workingFolder;
|
||||
try {
|
||||
File file = new File(workingFolder.getAbsolutePath() + File.separator + ".jmetestwrite");
|
||||
file.createNewFile();
|
||||
file.delete();
|
||||
extractionDir = workingFolder;
|
||||
} catch (Exception e) {
|
||||
setStorageExtractionDir();
|
||||
}
|
||||
}
|
||||
}
|
||||
return extractionDir;
|
||||
}
|
||||
|
||||
private static void setStorageExtractionDir() {
|
||||
logger.log(Level.WARNING, "Working directory is not writable. Using home directory instead.");
|
||||
extractionDir = new File(JmeSystem.getStorageFolder(),
|
||||
"natives_" + Integer.toHexString(computeNativesHash()));
|
||||
if (!extractionDir.exists()) {
|
||||
extractionDir.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
private static int computeNativesHash() {
|
||||
try {
|
||||
String classpath = System.getProperty("java.class.path");
|
||||
|
Loading…
x
Reference in New Issue
Block a user