diff --git a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties-MERGED b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties-MERGED index 40890b33de..eecf8f9614 100644 --- a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties-MERGED +++ b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/Bundle.properties-MERGED @@ -46,6 +46,7 @@ ConfigVisualPanel3.copyStatus.saved=Saved ConfigVisualPanel3.copyStatus.savingInProgress=Saving file, please wait # {0} - configurationLocation ConfigVisualPanel3.description.text=Press Save to write the imaging tool and configuration file to the destination.\nDestination: {0} +ConfigVisualPanel3.errorMsg.cannotFindLogicalImager=Cannot locate logical imager, cannot copy to destination # {0} - configFilename ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0} ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file diff --git a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel3.java b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel3.java index f9d61edeff..24c804c8e1 100644 --- a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel3.java +++ b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/ConfigVisualPanel3.java @@ -35,7 +35,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.coreutils.Logger; -import static org.sleuthkit.autopsy.logicalimager.configuration.CreateLogicalImagerAction.getTskLogicalImagerExe; +import static org.sleuthkit.autopsy.logicalimager.configuration.CreateLogicalImagerAction.getLogicalImagerExe; /** * Configuration visual panel 3 @@ -92,7 +92,8 @@ class ConfigVisualPanel3 extends javax.swing.JPanel { "ConfigVisualPanel3.failedToSaveConfigMsg=Failed to save configuration file: {0}", "# {0} - reason", "ConfigVisualPanel3.reason=\nReason: ", - "ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file",}) + "ConfigVisualPanel3.failedToSaveExeMsg=Failed to save tsk_logical_imager.exe file" + }) void saveConfigFile() { boolean saveSuccess = true; executableStatusLabel.setForeground(Color.BLACK); @@ -142,14 +143,22 @@ class ConfigVisualPanel3 extends javax.swing.JPanel { } /** - * Write the logical imager executable to the specified location + * Writes the logical imager executable to the specified location. * - * @param destDir the location to write the logical imager executable to + * @param destDir The destination directory. * - * @throws IOException + * @throws IOException If the executable cannot be found or copying fails. */ + @NbBundle.Messages({ + "ConfigVisualPanel3.errorMsg.cannotFindLogicalImager=Cannot locate logical imager, cannot copy to destination" + }) private void writeTskLogicalImagerExe(Path destDir) throws IOException { - FileUtils.copyFileToDirectory(getTskLogicalImagerExe(), destDir.toFile()); + File logicalImagerExe = getLogicalImagerExe(); + if (logicalImagerExe != null && logicalImagerExe.exists()) { + FileUtils.copyFileToDirectory(getLogicalImagerExe(), destDir.toFile()); + } else { + throw new IOException(Bundle.ConfigVisualPanel3_errorMsg_cannotFindLogicalImager()); + } } /** diff --git a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/CreateLogicalImagerAction.java b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/CreateLogicalImagerAction.java index ddb798512c..002b9a526e 100644 --- a/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/CreateLogicalImagerAction.java +++ b/Core/src/org/sleuthkit/autopsy/logicalimager/configuration/CreateLogicalImagerAction.java @@ -21,6 +21,8 @@ package org.sleuthkit.autopsy.logicalimager.configuration; import java.awt.Component; import java.awt.Dialog; import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; @@ -30,11 +32,11 @@ import org.openide.WizardDescriptor; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.awt.ActionRegistration; +import org.openide.modules.InstalledFileLocator; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.openide.util.actions.CallableSystemAction; -import static org.sleuthkit.autopsy.coreutils.PlatformUtil.getInstallModulesPath; /** * Configuration Logical Imager @@ -45,9 +47,19 @@ import static org.sleuthkit.autopsy.coreutils.PlatformUtil.getInstallModulesPath @Messages("CTL_CreateLogicalImagerAction=Create Logical Imager") public final class CreateLogicalImagerAction extends CallableSystemAction { - private static final String DISPLAY_NAME = Bundle.CTL_CreateLogicalImagerAction(); - private static final String TSK_LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS - private static final String TSK_LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS + private static final long serialVersionUID = 1L; + private static final String LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS + private static final String LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS + private static final Path LOGICAL_IMAGER_EXE_PATH = Paths.get(LOGICAL_IMAGER_DIR, LOGICAL_IMAGER_EXE); + + /** + * Finds the installed logical imager executable. + * + * @return A File object for the executable or null if it is not found. + */ + static File getLogicalImagerExe() { + return InstalledFileLocator.getDefault().locate(LOGICAL_IMAGER_EXE_PATH.toString(), CreateLogicalImagerAction.class.getPackage().getName(), false); + } @NbBundle.Messages({ "CreateLogicalImagerAction.title=Create Logical Imager" @@ -82,7 +94,7 @@ public final class CreateLogicalImagerAction extends CallableSystemAction { @Override public String getName() { - return DISPLAY_NAME; + return Bundle.CTL_CreateLogicalImagerAction(); } @Override @@ -92,13 +104,8 @@ public final class CreateLogicalImagerAction extends CallableSystemAction { @Override public boolean isEnabled() { - File tskLogicalImagerExe = getTskLogicalImagerExe(); - return tskLogicalImagerExe.exists(); + File logicalImagerExe = getLogicalImagerExe(); + return logicalImagerExe != null && logicalImagerExe.exists(); } - static public File getTskLogicalImagerExe() { - String installModulesPath = getInstallModulesPath(); - File tskLogicalImagerExe = new File(installModulesPath + File.separator + TSK_LOGICAL_IMAGER_DIR + File.separator + TSK_LOGICAL_IMAGER_EXE); - return tskLogicalImagerExe; - } } diff --git a/build-windows.xml b/build-windows.xml index 36b58d3900..27cbf31f26 100644 --- a/build-windows.xml +++ b/build-windows.xml @@ -8,7 +8,7 @@ - +