From ad87e7bcdbb60991ff5a38b7c13e545c24ba9448 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 630b1af..0f4f043 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")) { @@ -47,16 +48,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; }