Skip to content

Commit

Permalink
Fix for issue jMonkeyEngine#2302 - NativeLibraryLoader fails due to n…
Browse files Browse the repository at this point in the history
…o 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.
  • Loading branch information
andreas committed Aug 19, 2024
1 parent e2e9a94 commit b174117
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,15 @@ public static File getExtractionFolder() {
setExtractionFolderToUserCache();
} else {
try {
File jmeTempDir = new File(userTempDir, "jme3");
if (!jmeTempDir.exists()) {
jmeTempDir.mkdir();
}
extractionFolder = new File(jmeTempDir, "natives_" + Integer.toHexString(computeNativesHash()));
extractionFolder = new File(userTempDir, "jme3_natives_" + Integer.toHexString(computeNativesHash()));

if (!extractionFolder.exists()) {
extractionFolder.mkdir();
if(!extractionFolder.mkdir()) {
throw new IOException("Failed to create folder "+extractionFolder);
}
}
if(!extractionFolder.canWrite()) {
setExtractionFolderToUserCache();
}
} catch (Exception e) {
setExtractionFolderToUserCache();
Expand Down Expand Up @@ -268,7 +269,7 @@ private static void setExtractionFolderToUserCache() {
extractionFolder.mkdir();
}

logger.log(Level.WARNING, "Working directory is not writable. "
logger.log(Level.WARNING, "Temp directory is not writable. "
+ "Natives will be extracted to:\n{0}",
extractionFolder);
}
Expand Down

0 comments on commit b174117

Please sign in to comment.