Skip to content
This repository has been archived by the owner on Jun 23, 2019. It is now read-only.

Commit

Permalink
Fix library load failures on Windows caused by conflicts with existin…
Browse files Browse the repository at this point in the history
…g extracted temporary files
  • Loading branch information
cgutman committed May 22, 2016
1 parent a1ad2f9 commit 7121a84
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/com/limelight/binding/LibraryHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> avcDependencies = new HashSet<String>();
Expand All @@ -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")) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 7121a84

Please sign in to comment.