Skip to content
Snippets Groups Projects
Commit acf10571 authored by Brian Carrier's avatar Brian Carrier
Browse files

Merge pull request #280 from jawallace/temp_cleanup

try to delete legacy library files in the temp dir.
parents d4977f1f aa56b547
No related branches found
No related tags found
No related merge requests found
......@@ -23,8 +23,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
/**
* Collection of methods to load libraries embedded in the TSK Datamodel Jar file.
......@@ -155,8 +153,27 @@ private static boolean loadLibFromJar(Lib library) {
// copy library to temp folder and load it
try {
java.io.File libTemp = new java.io.File(System.getProperty("java.io.tmpdir") + java.io.File.separator + libName + libExt);
java.io.File tempFolder = new java.io.File(System.getProperty("java.io.tmpdir") + java.io.File.separator);
java.io.File libTemp = new java.io.File(tempFolder + libName + libExt);
// we used to copy dlls into here.
// delete any than may still exist from previous installations.
// Dec 2013
for (Lib l : Lib.values()) {
String ext = getExtByPlatform();
java.io.File f = new java.io.File(l.getLibName() + ext);
System.out.println(f.getName());
if (f.exists()) {
f.delete();
} else {
java.io.File fUnix = new java.io.File(l.getUnixName() + ext);
System.out.println(fUnix.getName());
if (fUnix.exists()) {
fUnix.delete();
}
}
}
if(libTemp.exists()) {
// Delete old file
libTemp.delete();
......@@ -180,4 +197,14 @@ private static boolean loadLibFromJar(Lib library) {
}
return true;
}
private static String getExtByPlatform() {
if (isWindows()) {
return ".dll";
} else if (isMac()) {
return ".dylib";
} else {
return ".so";
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment