mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Tweak ExternalViewerAction to require file extensions
This commit is contained in:
parent
b4ab34e03a
commit
3b61d89787
@ -43,8 +43,14 @@ public class ExternalViewerAction extends AbstractAction {
|
|||||||
public ExternalViewerAction(String title, Node fileNode) {
|
public ExternalViewerAction(String title, Node fileNode) {
|
||||||
super(title);
|
super(title);
|
||||||
this.fileObject = fileNode.getLookup().lookup(org.sleuthkit.datamodel.File.class);
|
this.fileObject = fileNode.getLookup().lookup(org.sleuthkit.datamodel.File.class);
|
||||||
|
|
||||||
long size = fileObject.getSize();
|
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);
|
this.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,10 +59,6 @@ public class ExternalViewerAction extends AbstractAction {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Log.noteAction(this.getClass());
|
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
|
// Get the temp folder path of the case
|
||||||
String tempPath = Case.getCurrentCase().getTempDirectory();
|
String tempPath = Case.getCurrentCase().getTempDirectory();
|
||||||
tempPath = tempPath + File.separator + this.fileObject.getName();
|
tempPath = tempPath + File.separator + this.fileObject.getName();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user