mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #4022 from dgrove727/4033_SaveLastExportLocation_1
4033 save last export location 1
This commit is contained in:
commit
15ec0ca5f2
@ -53,6 +53,8 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
|
|
||||||
private Logger logger = Logger.getLogger(ExtractAction.class.getName());
|
private Logger logger = Logger.getLogger(ExtractAction.class.getName());
|
||||||
|
|
||||||
|
private String userDefinedExportPath;
|
||||||
|
|
||||||
// This class is a singleton to support multi-selection of nodes, since
|
// This class is a singleton to support multi-selection of nodes, since
|
||||||
// org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
|
// org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
|
||||||
// node in the array returns a reference to the same action object from Node.getActions(boolean).
|
// node in the array returns a reference to the same action object from Node.getActions(boolean).
|
||||||
@ -110,10 +112,12 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
JFileChooser fileChooser = new JFileChooser();
|
||||||
fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
|
fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
|
||||||
// If there is an attribute name, change the ":". Otherwise the extracted file will be hidden
|
// If there is an attribute name, change the ":". Otherwise the extracted file will be hidden
|
||||||
fileChooser.setSelectedFile(new File(FileUtil.escapeFileName(selectedFile.getName())));
|
fileChooser.setSelectedFile(new File(FileUtil.escapeFileName(selectedFile.getName())));
|
||||||
if (fileChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) {
|
if (fileChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
updateExportDirectory(fileChooser.getSelectedFile().getParent(), openCase);
|
||||||
|
|
||||||
ArrayList<FileExtractionTask> fileExtractionTasks = new ArrayList<>();
|
ArrayList<FileExtractionTask> fileExtractionTasks = new ArrayList<>();
|
||||||
fileExtractionTasks.add(new FileExtractionTask(selectedFile, fileChooser.getSelectedFile()));
|
fileExtractionTasks.add(new FileExtractionTask(selectedFile, fileChooser.getSelectedFile()));
|
||||||
runExtractionTasks(event, fileExtractionTasks);
|
runExtractionTasks(event, fileExtractionTasks);
|
||||||
@ -137,7 +141,7 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
JFileChooser folderChooser = new JFileChooser();
|
JFileChooser folderChooser = new JFileChooser();
|
||||||
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
folderChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
|
folderChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
|
||||||
if (folderChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) {
|
if (folderChooser.showSaveDialog((Component) event.getSource()) == JFileChooser.APPROVE_OPTION) {
|
||||||
File destinationFolder = folderChooser.getSelectedFile();
|
File destinationFolder = folderChooser.getSelectedFile();
|
||||||
if (!destinationFolder.exists()) {
|
if (!destinationFolder.exists()) {
|
||||||
@ -150,6 +154,7 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateExportDirectory(destinationFolder.getPath(), openCase);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get the unique set of files from the list. A user once reported
|
* get the unique set of files from the list. A user once reported
|
||||||
@ -169,6 +174,45 @@ public final class ExtractAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the export directory path.
|
||||||
|
*
|
||||||
|
* @param openCase The current case.
|
||||||
|
*
|
||||||
|
* @return The export directory path.
|
||||||
|
*/
|
||||||
|
private String getExportDirectory(Case openCase) {
|
||||||
|
String caseExportPath = openCase.getExportDirectory();
|
||||||
|
|
||||||
|
if (userDefinedExportPath == null) {
|
||||||
|
return caseExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(userDefinedExportPath);
|
||||||
|
if (file.exists() == false || file.isDirectory() == false) {
|
||||||
|
return caseExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return userDefinedExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the default export directory. If the directory path matches the
|
||||||
|
* case export directory, then the directory used will always match the
|
||||||
|
* export directory of any given case. Otherwise, the path last used will be
|
||||||
|
* saved.
|
||||||
|
*
|
||||||
|
* @param exportPath The export path.
|
||||||
|
* @param openCase The current case.
|
||||||
|
*/
|
||||||
|
private void updateExportDirectory(String exportPath, Case openCase) {
|
||||||
|
if (exportPath.equalsIgnoreCase(openCase.getExportDirectory())) {
|
||||||
|
userDefinedExportPath = null;
|
||||||
|
} else {
|
||||||
|
userDefinedExportPath = exportPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a series of file extraction tasks.
|
* Execute a series of file extraction tasks.
|
||||||
*
|
*
|
||||||
|
@ -67,6 +67,7 @@ final class ExtractUnallocAction extends AbstractAction {
|
|||||||
private final List<OutputFileData> filesToExtract = new ArrayList<>();
|
private final List<OutputFileData> filesToExtract = new ArrayList<>();
|
||||||
private static final Set<String> volumesInProgress = new HashSet<>();
|
private static final Set<String> volumesInProgress = new HashSet<>();
|
||||||
private static final Set<Long> imagesInProgress = new HashSet<>();
|
private static final Set<Long> imagesInProgress = new HashSet<>();
|
||||||
|
private static String userDefinedExportPath;
|
||||||
private long currentImage = 0L;
|
private long currentImage = 0L;
|
||||||
private final boolean isImage;
|
private final boolean isImage;
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ final class ExtractUnallocAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fileChooser.setCurrentDirectory(new File(openCase.getExportDirectory()));
|
fileChooser.setCurrentDirectory(new File(getExportDirectory(openCase)));
|
||||||
fileChooser.setDialogTitle(
|
fileChooser.setDialogTitle(
|
||||||
NbBundle.getMessage(this.getClass(), "ExtractUnallocAction.dlgTitle.selectDirToSaveTo.msg"));
|
NbBundle.getMessage(this.getClass(), "ExtractUnallocAction.dlgTitle.selectDirToSaveTo.msg"));
|
||||||
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
@ -167,6 +168,9 @@ final class ExtractUnallocAction extends AbstractAction {
|
|||||||
int returnValue = fileChooser.showSaveDialog((Component) event.getSource());
|
int returnValue = fileChooser.showSaveDialog((Component) event.getSource());
|
||||||
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
if (returnValue == JFileChooser.APPROVE_OPTION) {
|
||||||
String destination = fileChooser.getSelectedFile().getPath();
|
String destination = fileChooser.getSelectedFile().getPath();
|
||||||
|
|
||||||
|
updateExportDirectory(destination, openCase);
|
||||||
|
|
||||||
for (OutputFileData outputFileData : filesToExtract) {
|
for (OutputFileData outputFileData : filesToExtract) {
|
||||||
outputFileData.setPath(destination);
|
outputFileData.setPath(destination);
|
||||||
|
|
||||||
@ -228,7 +232,45 @@ final class ExtractUnallocAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the export directory path.
|
||||||
|
*
|
||||||
|
* @param openCase The current case.
|
||||||
|
*
|
||||||
|
* @return The export directory path.
|
||||||
|
*/
|
||||||
|
private String getExportDirectory(Case openCase) {
|
||||||
|
String caseExportPath = openCase.getExportDirectory();
|
||||||
|
|
||||||
|
if (userDefinedExportPath == null) {
|
||||||
|
return caseExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
File file = new File(userDefinedExportPath);
|
||||||
|
if (file.exists() == false || file.isDirectory() == false) {
|
||||||
|
return caseExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
return userDefinedExportPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the default export directory. If the directory path matches the
|
||||||
|
* case export directory, then the directory used will always match the
|
||||||
|
* export directory of any given case. Otherwise, the path last used will be
|
||||||
|
* saved.
|
||||||
|
*
|
||||||
|
* @param exportPath The export path.
|
||||||
|
* @param openCase The current case.
|
||||||
|
*/
|
||||||
|
private void updateExportDirectory(String exportPath, Case openCase) {
|
||||||
|
if (exportPath.equalsIgnoreCase(openCase.getExportDirectory())) {
|
||||||
|
userDefinedExportPath = null;
|
||||||
|
} else {
|
||||||
|
userDefinedExportPath = exportPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user