From 7121a84afd590b31bb0d235eb8677e7bd9bcd3c1 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 22 May 2016 15:24:58 -0500 Subject: [PATCH] Fix library load failures on Windows caused by conflicts with existing extracted temporary files --- src/com/limelight/binding/LibraryHelper.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/limelight/binding/LibraryHelper.java b/src/com/limelight/binding/LibraryHelper.java index 8b4dda5..91eee25 100644 --- a/src/com/limelight/binding/LibraryHelper.java +++ b/src/com/limelight/binding/LibraryHelper.java @@ -9,6 +9,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; +import java.util.UUID; public class LibraryHelper { private static final HashSet avcDependencies = new HashSet(); @@ -19,7 +20,7 @@ public class LibraryHelper { static { needsDependencyExtraction = System.getProperty("os.name").contains("Windows"); - libraryExtractionFolder = System.getProperty("java.io.tmpdir", "."); + libraryExtractionFolder = System.getProperty("java.io.tmpdir", ".") + File.separatorChar + UUID.randomUUID().toString(); // AVC dependencies if (System.getProperty("os.name").contains("Windows")) { @@ -48,16 +49,19 @@ public static void loadNativeLibrary(String libraryName) { } public static void prepareNativeLibraries() { - if (!needsDependencyExtraction) { + if (!needsDependencyExtraction || !isRunningFromJar()) { return; } + // Create the native library folder + new File(libraryExtractionFolder).mkdirs(); + try { for (String dependency : avcDependencies) { extractNativeLibrary(dependency); } } catch (IOException e) { - // This is expected if this code is not running from a JAR + e.printStackTrace(); return; }