set tsk temp directory

This commit is contained in:
Greg DiCristofaro 2024-04-16 17:58:55 -04:00
parent bf041ab06c
commit b2c674e6b3

View File

@ -66,11 +66,17 @@ public class Installer extends ModuleInstall {
private static final long serialVersionUID = 1L;
private static final String JAVA_TEMP = "java.io.tmpdir";
private static final String AUTOPSY_TEMP_DIR = "autopsy_temp";
private static final String TSK_TEMP = "tsk.tmpdir";
private final List<ModuleInstall> packageInstallers;
private static final Logger logger = Logger.getLogger(Installer.class.getName());
private static volatile boolean javaFxInit = false;
static {
setTskTemp();
loadDynLibraries();
// This call was moved from MediaViewImagePanel so that it is
@ -81,6 +87,24 @@ public class Installer extends ModuleInstall {
OpenCvLoader.openCvIsLoaded();
}
/**
* Set TSK temp directory to de-conflict with other programs using TSK libs.
*/
private static void setTskTemp() {
try {
String curTemp = System.getProperty(JAVA_TEMP, "");
String tskTemp = curTemp + (curTemp.endsWith(File.separator) ? "" : File.separator) + AUTOPSY_TEMP_DIR;
System.setProperty(TSK_TEMP, tskTemp);
File tskTempDir = new File(tskTemp);
tskTempDir.mkdirs();
if (!tskTempDir.isDirectory()) {
throw new IOException("Unable to create directory at " + tskTemp);
}
} catch (Exception ex) {
logger.log(Level.WARNING, "There was an error setting up tsk temp directory", ex);
}
}
private static void loadDynLibraries() {
/*
* On Windows, we distribute dlls that libtsk_jni depend on. If