Unalloc checks for invalid folders.

Should no longer be able to get itself into an uncancellable state.
This commit is contained in:
0xNF 2012-12-21 09:40:07 -05:00
parent f5e6ec64f4
commit 347f4afb32

View File

@ -104,15 +104,25 @@ public final class ExtractUnallocAction extends AbstractAction {
}; };
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser() {
fc.setCurrentDirectory(new File(Case.getCurrentCase().getCaseDirectory())); @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.setDialogTitle("Select directory to save to");
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(false); fc.setAcceptAllFileFilterUsed(false);
int returnValue = fc.showSaveDialog((Component) e.getSource()); int returnValue = fc.showSaveDialog((Component) e.getSource());
if (returnValue == JFileChooser.APPROVE_OPTION) { if (returnValue == JFileChooser.APPROVE_OPTION) {
String destination = fc.getSelectedFile().getPath(); String destination = fc.getSelectedFile().getPath();
for (UnallocStruct u : LstUnallocs) { for (UnallocStruct u : LstUnallocs) {
u.setPath(destination); u.setPath(destination);
if (u.llf != null && u.llf.size() > 0 && !lockedVols.contains(u.getFileName())) { if (u.llf != null && u.llf.size() > 0 && !lockedVols.contains(u.getFileName())) {