Package ghidra.framework.data
Class LinkedGhidraFolder
java.lang.Object
ghidra.framework.data.LinkedGhidraFolder
- All Implemented Interfaces:
DomainFolder,LinkedDomainFolder,Comparable<DomainFolder>
LinkedGhidraFolder provides the base LinkedDomainFolder implementation which
corresponds to a project folder-link (see FolderLinkContentHandler).-
Field Summary
FieldsFields inherited from interface ghidra.framework.model.DomainFolder
CLOSED_FOLDER_ICON, COPY_SUFFIX, OPEN_FOLDER_ICON, SEPARATOR -
Method Summary
Modifier and TypeMethodDescriptionintcopyTo(DomainFolder newParent, TaskMonitor monitor) Copy this folder into the newParent folder.copyToAsLink(DomainFolder newParent, boolean relative) Copy this folder into the newParent folder as a folder-link.createFile(String name, DomainObject obj, TaskMonitor monitor) Add a domain object to this folder.createFile(String name, File packFile, TaskMonitor monitor) Add a new domain file to this folder.createFolder(String name) Create a subfolder within this folder.createLinkFile(ProjectData sourceProjectData, String pathname, boolean makeRelative, String linkFilename, LinkHandler<?> lh) Create a link-file within this folder which references the specified file or folderpathnamewithin the project specified bysourceProjectData.createLinkFile(String ghidraUrl, String linkFilename, LinkHandler<?> lh) Create an external link-file within this folder which references the specifiedghidraUrland whose content is defined by the specifiedlhinstance.voiddelete()Deletes this folder, if empty, from the local filesystembooleanGet the domain file in this folder with the given name.getFiles()Get all domain files in this folder.ghidra.framework.data.LinkedGhidraSubFolderReturn the folder for the given name.ghidra.framework.data.LinkedGhidraSubFolder[]Get DomainFolders in this folder.getIcon(boolean isOpen) Get the appropriate icon for this foldergetLinkedFileNoError(String name) Get the true file within this linked folder.Get the project folder/file pathname for this this linked-folder relative to the linked-folder root.Get the project data that corresponds to the linked-project and contains theLinkedDomainFolder.getLinkedPathname()which corresponds to this folder.Get a local Ghidra URL for this domain file if available within the associated non-transient local project.getName()Return this folder's name.Return parent folder or null if this DomainFolder is the root folder.Returns the full path name to this folderReturns the project dataReturns the local storage location for the project that this DomainFolder belongs to.Get the Ghidra URL of the project/repository folder referenced by this objectGet the real domain folder which corresponds to this linked-folder.Get a remote Ghidra URL for this domain folder if available within an associated shared project repository.inthashCode()booleanisEmpty()Determine if this folder contains any sub-folders or domain files.booleanDetermine if this folder resides within an external project or repository.booleanReturns true if this file is in a writable project.booleanisLinked()Determine if this folder corresponds to a linked-folder which directly corresponds to a folder-link file.booleanisSame(DomainFolder folder) Returns true if the given folder is the same as this folder based on path and underlying project/repository.booleanisSameOrAncestor(DomainFolder folder) Returns true if the given folder is the same or a child of this folder or one of its descendants based on path and underlying project/repository.booleanDetermine if this linked-folder corresponds to an external URL linkage and not an internal project linkage.moveTo(DomainFolder newParent) Move this folder into the newParent folder.voidAllows the framework to react to a request to make this folder the "active" one.Set the name on this domain folder.toString()
-
Field Details
-
FOLDER_LINK_CLOSED_ICON
-
FOLDER_LINK_OPEN_ICON
-
-
Method Details
-
equals
-
isExternal
public boolean isExternal()Description copied from interface:LinkedDomainFolderDetermine if this folder resides within an external project or repository. The term "external" means the actual folder does not reside within the same project as the folder-link that referenced it and which was used to produce this linked folder instance.- Specified by:
isExternalin interfaceLinkedDomainFolder- Returns:
- true if linked-folder is external to the link file which was used to access, else false if internal to the same project.
-
getProjectURL
Get the Ghidra URL of the project/repository folder referenced by this object- Returns:
- Ghidra URL of the project/repository folder referenced by this object
-
isInWritableProject
public boolean isInWritableProject()Description copied from interface:DomainFolderReturns true if this file is in a writable project.- Specified by:
isInWritableProjectin interfaceDomainFolder- Returns:
- true if writable
-
getLinkedProjectData
Description copied from interface:LinkedDomainFolderGet the project data that corresponds to the linked-project and contains theLinkedDomainFolder.getLinkedPathname()which corresponds to this folder.- Specified by:
getLinkedProjectDatain interfaceLinkedDomainFolder- Returns:
- linked project data
- Throws:
IOException- if an IO error occurs
-
getLinkedPathname
Description copied from interface:LinkedDomainFolderGet the project folder/file pathname for this this linked-folder relative to the linked-folder root.- Specified by:
getLinkedPathnamein interfaceLinkedDomainFolder- Returns:
- project pathname
-
getRealFolder
Description copied from interface:LinkedDomainFolderGet the real domain folder which corresponds to this linked-folder. In the process of resolving the real folder a remote project or repository may be required.- Specified by:
getRealFolderin interfaceLinkedDomainFolder- Returns:
- domain folder
- Throws:
IOException- if an IO error occurs while connecting/accessing the associated project or repository.
-
getProjectLocator
Description copied from interface:DomainFolderReturns the local storage location for the project that this DomainFolder belongs to.- Specified by:
getProjectLocatorin interfaceDomainFolder- Returns:
- the locator
-
getProjectData
Description copied from interface:DomainFolderReturns the project data- Specified by:
getProjectDatain interfaceDomainFolder- Returns:
- the project data
-
getParent
Description copied from interface:DomainFolderReturn parent folder or null if this DomainFolder is the root folder.- Specified by:
getParentin interfaceDomainFolder- Returns:
- the parent
-
setName
Description copied from interface:DomainFolderSet the name on this domain folder.- Specified by:
setNamein interfaceDomainFolder- Parameters:
newName- domain folder name- Returns:
- renamed domain file (the original DomainFolder object becomes invalid since it is immutable)
- Throws:
InvalidNameException- if newName contains illegal charactersIOException- thrown if an IO or access error occurs.
-
toString
-
getIcon
Description copied from interface:LinkedDomainFolderGet the appropriate icon for this folder- Specified by:
getIconin interfaceLinkedDomainFolder- Parameters:
isOpen- true if open icon, false for closed- Returns:
- folder icon
-
isLinked
public boolean isLinked()Description copied from interface:DomainFolderDetermine if this folder corresponds to a linked-folder which directly corresponds to a folder-link file. While this method is useful for identify a linked-folder root, in some cases it may be preferrable to simply check for instanceofLinkedDomainFolderwhich applies to the linked-folder root as well as its child sub-folders.- Returns:
- true if folder corresponds to a linked-folder, else false.
-
isUrlLinked
public boolean isUrlLinked()Determine if this linked-folder corresponds to an external URL linkage and not an internal project linkage.- Returns:
- true if linked based on external URL
-
getName
Description copied from interface:DomainFolderReturn this folder's name.- Specified by:
getNamein interfaceDomainFolder- Returns:
- the name
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareToin interfaceComparable<DomainFolder>
-
isSame
Description copied from interface:DomainFolderReturns true if the given folder is the same as this folder based on path and underlying project/repository. Unlike theObject.equals(Object)check, this method handles cases where the folder provided may correspond to another project instance which is considered the same as the project that this folder is contained within.- Specified by:
isSamein interfaceDomainFolder- Parameters:
folder- the potential same or descendant folder to check- Returns:
- true if the given folder is the same or a child of this folder or one of its descendants.
-
isSameOrAncestor
Description copied from interface:DomainFolderReturns true if the given folder is the same or a child of this folder or one of its descendants based on path and underlying project/repository. Unlike theObject.equals(Object)check, this method handles cases where the folder provided may correspond to another project instance which is considered the same as the project that this folder is contained within.- Specified by:
isSameOrAncestorin interfaceDomainFolder- Parameters:
folder- the potential same or descendant folder to check- Returns:
- true if the given folder is the same or a child of this folder or one of its descendants.
-
getLocalProjectURL
Description copied from interface:DomainFolderGet a local Ghidra URL for this domain file if available within the associated non-transient local project. A null value will be returned if project is transient.- Specified by:
getLocalProjectURLin interfaceDomainFolder- Returns:
- local Ghidra URL for this folder or null if transient or not applicable
-
getPathname
Description copied from interface:DomainFolderReturns the full path name to this folder- Specified by:
getPathnamein interfaceDomainFolder- Returns:
- the path name
-
getFolders
public ghidra.framework.data.LinkedGhidraSubFolder[] getFolders()Description copied from interface:DomainFolderGet DomainFolders in this folder. This may return cached information and does not force a full refresh.- Specified by:
getFoldersin interfaceDomainFolder- Returns:
- list of sub-folders
-
getFolder
Description copied from interface:DomainFolderReturn the folder for the given name. Folder link-files are ignored.- Specified by:
getFolderin interfaceDomainFolder- Parameters:
name- of folder to retrieve- Returns:
- folder or null if there is no folder by the given name.
-
getFiles
Description copied from interface:DomainFolderGet all domain files in this folder. This may return cached information and does not force a full refresh.- Specified by:
getFilesin interfaceDomainFolder- Returns:
- list of domain files
-
getLinkedFileNoError
Get the true file within this linked folder.NOTE: The returned file is the "real" file and would be the have the equivalence:
folder.getLinkedFileNoError("X") == folder.getFile("X").getRealFile().- Parameters:
name- file name- Returns:
- file or null if not found or error occurs
-
getFile
Description copied from interface:DomainFolderGet the domain file in this folder with the given name.- Specified by:
getFilein interfaceDomainFolder- Parameters:
name- name of file in this folder to retrieve- Returns:
- domain file or null if there is no domain file in this folder with the given name.
-
isEmpty
public boolean isEmpty()Description copied from interface:DomainFolderDetermine if this folder contains any sub-folders or domain files.- Specified by:
isEmptyin interfaceDomainFolder- Returns:
- true if this folder is empty.
-
createFile
public DomainFile createFile(String name, DomainObject obj, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException Description copied from interface:DomainFolderAdd a domain object to this folder.- Specified by:
createFilein interfaceDomainFolder- Parameters:
name- domain file nameobj- domain object to be storedmonitor- progress monitor- Returns:
- domain file created as a result of adding the domain object to this folder
- Throws:
InvalidNameException- if name is an empty string or if it contains characters other than alphanumerics.IOException- if IO or access error occursCancelledException- if the user cancels the create.
-
createFile
public DomainFile createFile(String name, File packFile, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException Description copied from interface:DomainFolderAdd a new domain file to this folder.- Specified by:
createFilein interfaceDomainFolder- Parameters:
name- domain file namepackFile- packed file containing domain file datamonitor- progress monitor- Returns:
- domain file created as a result of adding the domain object to this folder
- Throws:
InvalidNameException- if name is an empty string or if it contains characters other than alphanumerics.IOException- if IO or access error occursCancelledException- if the user cancels the create.
-
createLinkFile
public DomainFile createLinkFile(ProjectData sourceProjectData, String pathname, boolean makeRelative, String linkFilename, LinkHandler<?> lh) throws IOException Description copied from interface:DomainFolderCreate a link-file within this folder which references the specified file or folderpathnamewithin the project specified bysourceProjectData. The link-file may correspond to various types of content (e.g., Program, Trace, Folder, etc.) based upon the specifiedLinkHandlerinstance.- Specified by:
createLinkFilein interfaceDomainFolder- Parameters:
sourceProjectData- referenced content project data within which specified path exists. If this differ's from this folder's project a Ghidra URL will be used, otherwise and internal link path reference will be used.pathname- an absolute path of project folder or file within the specified source project data (a Ghidra URL is not permitted)makeRelative- if true, and this file is contained within the same activeProjectDatainstance asnewParent, an internal-project relative path link-file will be created.linkFilename- name of link-file to be created within this folder. NOTE: This name may be modified to ensure uniqueness within this folder.lh- link-file handler used to create specific link-file (see derived implementations ofLinkHandlerand their public static INSTANCE.- Returns:
- newly created link-file
- Throws:
IOException- if IO error occurs during link creation
-
createLinkFile
public DomainFile createLinkFile(String ghidraUrl, String linkFilename, LinkHandler<?> lh) throws IOException Description copied from interface:DomainFolderCreate an external link-file within this folder which references the specifiedghidraUrland whose content is defined by the specifiedlhinstance.- Specified by:
createLinkFilein interfaceDomainFolder- Parameters:
ghidraUrl- a Ghidra URL which corresponds to a file or a folder based on the designatedlhinstance. Only rudimentary URL checks are performed.linkFilename- name of link-file to be created within this folder. NOTE: This name may be modified to ensure uniqueness within this folder.lh- link-file handler used to create specific link-file (see derived implementations ofLinkHandlerand their public static INSTANCE.- Returns:
- newly created link-file
- Throws:
IOException- if IO error occurs during link creation
-
createFolder
Description copied from interface:DomainFolderCreate a subfolder within this folder.- Specified by:
createFolderin interfaceDomainFolder- Parameters:
name- sub-folder name- Returns:
- the new folder
- Throws:
InvalidNameException- if name is an empty string of if it contains characters other than alphanumerics.IOException- if IO or access error occurs
-
delete
Description copied from interface:DomainFolderDeletes this folder, if empty, from the local filesystem- Specified by:
deletein interfaceDomainFolder- Throws:
IOException- if IO or access error occurs
-
moveTo
Description copied from interface:DomainFolderMove this folder into the newParent folder. If connected to a repository this moves both private and repository folders/files. If not connected, only private folders/files are moved.- Specified by:
moveToin interfaceDomainFolder- Parameters:
newParent- new parent folder within the same project- Returns:
- the newly relocated folder (the original DomainFolder object becomes invalid since it is immutable)
- Throws:
IOException- thrown if an IO or access error occurs.
-
copyTo
public DomainFolder copyTo(DomainFolder newParent, TaskMonitor monitor) throws IOException, CancelledException Description copied from interface:DomainFolderCopy this folder into the newParent folder.- Specified by:
copyToin interfaceDomainFolder- Parameters:
newParent- new parent foldermonitor- the task monitor- Returns:
- the new copied folder
- Throws:
IOException- thrown if an IO or access error occurs.CancelledException- if task monitor cancelled operation.
-
copyToAsLink
Description copied from interface:DomainFolderCopy this folder into the newParent folder as a folder-link. A folder-link references another folder without actually copying all of its children. If this folder is associated with a temporary transient project (i.e., not a locally managed project) the generated link will refer to the this folder with a Ghidra URL. If this folder is contained within the same activeProjectDatainstance asnewParentan internal link reference will be made.- Specified by:
copyToAsLinkin interfaceDomainFolder- Parameters:
newParent- new parent folder where link-file is to be createdrelative- if true, and this folder is contained within the same activeProjectDatainstance asnewParent, an internal-project relative path folder-link will be created.- Returns:
- newly created domain file which is a folder-link (i.e., link-file).
- Throws:
IOException- if an IO or access error occurs.
-
setActive
public void setActive()Description copied from interface:DomainFolderAllows the framework to react to a request to make this folder the "active" one.- Specified by:
setActivein interfaceDomainFolder
-