mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-22 04:05:39 +00:00
Merge remote-tracking branch 'origin/GP-5031_dev747368
This commit is contained in:
commit
860915d129
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -56,6 +56,7 @@ public enum FileAttributeType {
|
||||
|
||||
SYMLINK_DEST_ATTR("Symbolic link destination", MISC_INFO, String.class),
|
||||
COMMENT_ATTR("Comment", MISC_INFO, String.class),
|
||||
FILENAME_EXT_OVERRIDE("Extension override", MISC_INFO, String.class), // no leading '.'
|
||||
|
||||
UNKNOWN_ATTRIBUTE("Other attribute", ADDITIONAL_INFO, Object.class);
|
||||
|
||||
@ -63,7 +64,7 @@ public enum FileAttributeType {
|
||||
private final FileAttributeTypeGroup group;
|
||||
private final Class<?> valueType;
|
||||
|
||||
private FileAttributeType(String displayName, FileAttributeTypeGroup group,
|
||||
FileAttributeType(String displayName, FileAttributeTypeGroup group,
|
||||
Class<?> valueType) {
|
||||
this.displayName = displayName;
|
||||
this.group = group;
|
||||
|
@ -59,16 +59,13 @@ public class ImporterUtilities {
|
||||
|
||||
/**
|
||||
* File extension filter for well known 'loadable' files for GhidraFileChoosers.
|
||||
*
|
||||
* TODO: will be refactored to use file_extension_icon.xml file info.
|
||||
*/
|
||||
public static final GhidraFileFilter LOADABLE_FILES_FILTER = ExtensionFileFilter.forExtensions(
|
||||
"Loadable files", "exe", "dll", "obj", "drv", "bin", "hex", "o", "a", "so", "class", "lib", "dylib");
|
||||
"Loadable files", "exe", "dll", "obj", "drv", "bin", "hex", "o", "a", "so", "class", "lib",
|
||||
"dylib");
|
||||
|
||||
/**
|
||||
* File extension filter for well known 'container' files for GhidraFileChoosers.
|
||||
*
|
||||
* TODO: will be refactored to use file_extension_icon.xml file info.
|
||||
*/
|
||||
public static final GhidraFileFilter CONTAINER_FILES_FILTER =
|
||||
ExtensionFileFilter.forExtensions("Container files", "zip", "tar", "tgz", "jar", "gz",
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -192,9 +192,18 @@ public class FSBComponentProvider extends ComponentProviderAdapter
|
||||
overlays.add(FSBIcons.MISSING_PASSWORD_OVERLAY_ICON);
|
||||
}
|
||||
|
||||
String ext = node.getFilenameExtOverride();
|
||||
if (ext != null && !ext.isEmpty()) {
|
||||
if (ext.startsWith(".")) {
|
||||
Msg.error(this,
|
||||
"Extension override '" + ext + "' should not begin with a dot");
|
||||
} else {
|
||||
filename += "." + ext;
|
||||
}
|
||||
}
|
||||
|
||||
Icon icon = fsbIcons.getIcon(filename, overlays);
|
||||
setIcon(icon);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -38,6 +38,7 @@ public class FSBFileNode extends FSBNode {
|
||||
protected boolean hasPassword;
|
||||
protected String symlinkDest;
|
||||
protected long lastModified;
|
||||
protected String filenameExtOverride;
|
||||
|
||||
FSBFileNode(GFile file) {
|
||||
this.file = file;
|
||||
@ -83,6 +84,17 @@ public class FSBFileNode extends FSBNode {
|
||||
return symlinkDest != null;
|
||||
}
|
||||
|
||||
public String getFilenameExtOverride() {
|
||||
return filenameExtOverride;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFileExtension() {
|
||||
return filenameExtOverride != null && !filenameExtOverride.isEmpty()
|
||||
? filenameExtOverride
|
||||
: super.getFileExtension();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return file.hashCode();
|
||||
@ -95,6 +107,7 @@ public class FSBFileNode extends FSBNode {
|
||||
symlinkDest = fattrs.get(SYMLINK_DEST_ATTR, String.class, null);
|
||||
Date lastModDate = fattrs.get(MODIFIED_DATE_ATTR, Date.class, null);
|
||||
lastModified = lastModDate != null ? lastModDate.getTime() : 0;
|
||||
filenameExtOverride = fattrs.get(FILENAME_EXT_OVERRIDE, String.class, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -22,6 +22,8 @@ import java.util.stream.Collectors;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import docking.widgets.tree.GTreeNode;
|
||||
import docking.widgets.tree.GTreeSlowLoadingNode;
|
||||
import ghidra.formats.gfilesystem.*;
|
||||
@ -65,6 +67,15 @@ public abstract class FSBNode extends GTreeSlowLoadingNode {
|
||||
return getFSRL().getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the extension of this node's name, or "" if none
|
||||
*
|
||||
* @return extension of this node's name, or "" if none
|
||||
*/
|
||||
public String getFileExtension() {
|
||||
return FilenameUtils.getExtension(getName());
|
||||
}
|
||||
|
||||
public FSBRootNode getFSBRootNode() {
|
||||
GTreeNode node = getParent();
|
||||
while (node != null) {
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -22,8 +22,6 @@ import java.util.Set;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.builder.ActionBuilder;
|
||||
import docking.widgets.label.GIconLabel;
|
||||
@ -48,9 +46,7 @@ public class ImageFSBFileHandler implements FSBFileHandler {
|
||||
|
||||
@Override
|
||||
public boolean fileDefaultAction(FSBFileNode fileNode) {
|
||||
FSRL fsrl = fileNode.getFSRL();
|
||||
String extension = FilenameUtils.getExtension(fsrl.getName().toLowerCase());
|
||||
if (COMMON_IMAGE_EXTENSIONS.contains(extension)) {
|
||||
if (COMMON_IMAGE_EXTENSIONS.contains(fileNode.getFileExtension().toLowerCase())) {
|
||||
FSBComponentProvider fsbComponent = context.fsbComponent();
|
||||
fsbComponent.runTask(monitor -> doViewAsImage(fileNode.getFSRL(),
|
||||
fsbComponent.getComponent(), monitor));
|
||||
|
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -46,7 +46,7 @@ public class TextFSBFileHandler implements FSBFileHandler {
|
||||
|
||||
@Override
|
||||
public boolean fileDefaultAction(FSBFileNode fileNode) {
|
||||
if (fileNode.getName().toLowerCase().endsWith(".txt")) {
|
||||
if (fileNode.getFileExtension().equalsIgnoreCase("txt")) {
|
||||
FSBComponentProvider fsbComponent = context.fsbComponent();
|
||||
fsbComponent.runTask(
|
||||
monitor -> doViewAsText(fileNode.getFSRL(), fsbComponent.getComponent(), monitor));
|
||||
|
Loading…
Reference in New Issue
Block a user