mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
Merge pull request #2002 from BasisOlivers/aut-2028
Made file path save for hash db
This commit is contained in:
commit
e68ae86b3b
@ -30,6 +30,7 @@ import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JFrame;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType;
|
||||
@ -46,6 +47,7 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
|
||||
.getMessage(HashDbCreateDatabaseDialog.class, "HashDbCreateDatabaseDialog.defaultFileName");
|
||||
private JFileChooser fileChooser = null;
|
||||
private HashDb newHashDb = null;
|
||||
private final static String LAST_FILE_PATH_KEY = "HashDbCreate_Path";
|
||||
|
||||
/**
|
||||
* Displays a dialog that allows a user to create a new hash database and
|
||||
@ -273,17 +275,23 @@ final class HashDbCreateDatabaseDialog extends javax.swing.JDialog {
|
||||
|
||||
private void saveAsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsButtonActionPerformed
|
||||
try {
|
||||
String lastBaseDirectory = "";
|
||||
if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
|
||||
lastBaseDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY);
|
||||
}
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(lastBaseDirectory);
|
||||
if (!hashSetNameTextField.getText().isEmpty()) {
|
||||
path.append(hashSetNameTextField.getText());
|
||||
path.append(File.separator).append(hashSetNameTextField.getText());
|
||||
} else {
|
||||
path.append(DEFAULT_FILE_NAME);
|
||||
path.append(File.separator).append(DEFAULT_FILE_NAME);
|
||||
}
|
||||
path.append(".").append(HashDbManager.getHashDatabaseFileExtension());
|
||||
fileChooser.setSelectedFile(new File(path.toString()));
|
||||
if (fileChooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
File databaseFile = fileChooser.getSelectedFile();
|
||||
databasePathTextField.setText(databaseFile.getCanonicalPath());
|
||||
ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(HashDbCreateDatabaseDialog.class.getName()).log(Level.WARNING, "Couldn't get selected file path.", ex); //NON-NLS
|
||||
|
@ -32,6 +32,7 @@ import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.JFrame;
|
||||
import org.sleuthkit.datamodel.TskCoreException;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb.KnownFilesType;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDb;
|
||||
import org.sleuthkit.autopsy.modules.hashdatabase.HashDbManager.HashDbManagerException;
|
||||
@ -46,6 +47,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
|
||||
private JFileChooser fileChooser = new JFileChooser();
|
||||
private String selectedFilePath = "";
|
||||
private HashDb selectedHashDb = null;
|
||||
private final static String LAST_FILE_PATH_KEY = "HashDbImport_Path";
|
||||
|
||||
/**
|
||||
* Displays a dialog that allows a user to select an existing hash database
|
||||
@ -249,6 +251,9 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
|
||||
if (ModuleSettings.settingExists(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)) {
|
||||
fileChooser.setCurrentDirectory(new File(ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY)));
|
||||
}
|
||||
if (fileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||
File databaseFile = fileChooser.getSelectedFile();
|
||||
try {
|
||||
@ -259,6 +264,7 @@ final class HashDbImportDatabaseDialog extends javax.swing.JDialog {
|
||||
knownRadioButton.setSelected(true);
|
||||
knownRadioButtonActionPerformed(null);
|
||||
}
|
||||
ModuleSettings.setConfigSetting(ModuleSettings.MAIN_SETTINGS, LAST_FILE_PATH_KEY, databaseFile.getParent());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(HashDbImportDatabaseDialog.class.getName()).log(Level.SEVERE, "Failed to get path of selected database", ex); //NON-NLS
|
||||
JOptionPane.showMessageDialog(this,
|
||||
|
Loading…
x
Reference in New Issue
Block a user