Skip to content

Commit a9a3f3d

Browse files
terranprogandreasandreas
authored
Fix for issue jMonkeyEngine#2302 - NativeLibraryLoader fails due to no write permissions (jMonkeyEngine#2303)
* Fix for issue jMonkeyEngine#2302 - NativeLibraryLoader fails due to no write permissions Extract native library to a folder directly beneath the user temp folder. Do not use an intermediate /jme subfolder. Check the result of the call to mkdir. Use UserCache if creation failed. Check if the extraction folder is actually writable. If not use the UserCache. Updated log message: since a previous change we no longer extract to the working directory. * Switch to a smaller change. Simply check if jmeTempDir is writable. If not, use user cache folder instead. --------- Co-authored-by: andreas <awmross@test.com> Co-authored-by: andreas <amross@fastmail.com>
1 parent 3f7527a commit a9a3f3d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,14 @@ public static File getExtractionFolder() {
202202
if (!jmeTempDir.exists()) {
203203
jmeTempDir.mkdir();
204204
}
205-
extractionFolder = new File(jmeTempDir, "natives_" + Integer.toHexString(computeNativesHash()));
206-
207-
if (!extractionFolder.exists()) {
208-
extractionFolder.mkdir();
205+
if(!jmeTempDir.canWrite()) {
206+
setExtractionFolderToUserCache();
207+
} else {
208+
extractionFolder = new File(jmeTempDir, "natives_" + Integer.toHexString(computeNativesHash()));
209+
210+
if (!extractionFolder.exists()) {
211+
extractionFolder.mkdir();
212+
}
209213
}
210214
} catch (Exception e) {
211215
setExtractionFolderToUserCache();
@@ -268,7 +272,7 @@ private static void setExtractionFolderToUserCache() {
268272
extractionFolder.mkdir();
269273
}
270274

271-
logger.log(Level.WARNING, "Working directory is not writable. "
275+
logger.log(Level.WARNING, "Temp directory is not writable. "
272276
+ "Natives will be extracted to:\n{0}",
273277
extractionFolder);
274278
}

0 commit comments

Comments
 (0)