From 347f4afb3277bff6ac63b48a6bc3978f4dfcaaf4 Mon Sep 17 00:00:00 2001 From: 0xNF Date: Fri, 21 Dec 2012 09:40:07 -0500 Subject: [PATCH] Unalloc checks for invalid folders. Should no longer be able to get itself into an uncancellable state. --- .../directorytree/ExtractUnallocAction.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java index 02c7a4a1e0..4eb8d84bb5 100644 --- a/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java +++ b/Core/src/org/sleuthkit/autopsy/directorytree/ExtractUnallocAction.java @@ -104,15 +104,25 @@ public final class ExtractUnallocAction extends AbstractAction { }; - JFileChooser fc = new JFileChooser(); - fc.setCurrentDirectory(new File(Case.getCurrentCase().getCaseDirectory())); + JFileChooser fc = new JFileChooser() { + @Override + public void approveSelection() { + File f = getSelectedFile(); + if (!f.exists() && getDialogType() == SAVE_DIALOG || !f.canWrite()) { + JOptionPane.showMessageDialog(this, "Folder does not exist. Please choose a valid folder before continuing"); + return; + } + super.approveSelection(); + } + }; + + fc.setCurrentDirectory(new File(Case.getCurrentCase().getCaseDirectory() + File.separator + "Export")); fc.setDialogTitle("Select directory to save to"); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setAcceptAllFileFilterUsed(false); int returnValue = fc.showSaveDialog((Component) e.getSource()); if (returnValue == JFileChooser.APPROVE_OPTION) { String destination = fc.getSelectedFile().getPath(); - for (UnallocStruct u : LstUnallocs) { u.setPath(destination); if (u.llf != null && u.llf.size() > 0 && !lockedVols.contains(u.getFileName())) {