Skip to content
Snippets Groups Projects
Commit fbc8a682 authored by Jeff Wallace's avatar Jeff Wallace
Browse files

Replaced file deletion method to be jdk6 compatible.

parent a9a6fcca
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.nio.file.Files;
/** /**
* Collection of methods to load libraries embedded in the TSK Datamodel Jar file. * Collection of methods to load libraries embedded in the TSK Datamodel Jar file.
...@@ -23,6 +22,7 @@ public class LibraryUtils { ...@@ -23,6 +22,7 @@ public class LibraryUtils {
public static final Lib[] CRT_LIBS = new Lib[] { Lib.MSVCP, Lib.MSVCR }; public static final Lib[] CRT_LIBS = new Lib[] { Lib.MSVCP, Lib.MSVCR };
public static final Lib[] OTHER_LIBS = new Lib[] { Lib.ZLIB, Lib.LIBEWF, Lib.TSK_JNI }; public static final Lib[] OTHER_LIBS = new Lib[] { Lib.ZLIB, Lib.LIBEWF, Lib.TSK_JNI };
/** /**
* The libraries the TSK Datamodel needs. * The libraries the TSK Datamodel needs.
*/ */
...@@ -72,6 +72,15 @@ public static boolean isWindows() { ...@@ -72,6 +72,15 @@ public static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows"); return System.getProperty("os.name").toLowerCase().contains("windows");
} }
/**
* Is the platform Mac?
*
* @return
*/
private static boolean isMac() {
return System.getProperty("os.name").toLowerCase().contains("mac");
}
/** /**
* Attempt to extract and load the specified library. * Attempt to extract and load the specified library.
* *
...@@ -84,7 +93,7 @@ public static void loadLibrary(Lib library) { ...@@ -84,7 +93,7 @@ public static void loadLibrary(Lib library) {
path.append(getPlatform()); path.append(getPlatform());
String libName = library.getLibName(); String libName = library.getLibName();
if(library == Lib.TSK_JNI && isWindows()) { if(library == Lib.TSK_JNI && (isWindows() || isMac())) {
libName = "lib" + libName; libName = "lib" + libName;
} }
...@@ -108,7 +117,7 @@ public static void loadLibrary(Lib library) { ...@@ -108,7 +117,7 @@ public static void loadLibrary(Lib library) {
if(libTemp.exists()) { if(libTemp.exists()) {
// Delete old file // Delete old file
Files.delete(libTemp.toPath()); libTemp.delete();
} }
InputStream in = libraryURL.openStream(); InputStream in = libraryURL.openStream();
...@@ -122,9 +131,12 @@ public static void loadLibrary(Lib library) { ...@@ -122,9 +131,12 @@ public static void loadLibrary(Lib library) {
in.close(); in.close();
out.close(); out.close();
System.out.println(libTemp.getAbsolutePath());
System.load(libTemp.getAbsolutePath()); System.load(libTemp.getAbsolutePath());
} catch (IOException e) { } catch (IOException e) {
// Loading failed. System.out.println("IO Exception:");
System.out.println(System.getProperty("java.io.tmpdir"));
e.printStackTrace();
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment