diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java index e3a8e1bc31..f772b4528b 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ExternalViewerAction.java @@ -43,8 +43,14 @@ public class ExternalViewerAction extends AbstractAction { public ExternalViewerAction(String title, Node fileNode) { super(title); this.fileObject = fileNode.getLookup().lookup(org.sleuthkit.datamodel.File.class); + long size = fileObject.getSize(); - if (!(size > 0)) { + String fileName = fileObject.getName(); + int extPos = fileName.lastIndexOf('.'); + + // no point opening a file if it's empty, and java doesn't know how to + // find an application for files without an extension + if (!(size > 0) || extPos == -1) { this.setEnabled(false); } } @@ -53,10 +59,6 @@ public class ExternalViewerAction extends AbstractAction { public void actionPerformed(ActionEvent e) { Log.noteAction(this.getClass()); - - // the menu should be disabled if we can't read the content (for example: on zero-sized file). - // Therefore, it should never throw the TSKException. - // Get the temp folder path of the case String tempPath = Case.getCurrentCase().getTempDirectory(); tempPath = tempPath + File.separator + this.fileObject.getName();