Package ghidra.framework.data
Class GhidraFolder
- java.lang.Object
-
- ghidra.framework.data.GhidraFolder
-
- All Implemented Interfaces:
DomainFolder
,java.lang.Comparable<DomainFolder>
- Direct Known Subclasses:
RootGhidraFolder
public class GhidraFolder extends java.lang.Object implements DomainFolder
-
-
Field Summary
-
Fields inherited from interface ghidra.framework.model.DomainFolder
COPY_SUFFIX, SEPARATOR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(DomainFolder df)
GhidraFolder
copyTo(DomainFolder newParent, TaskMonitor monitor)
Copy this folder into the newParent folder.DomainFile
createFile(java.lang.String fileName, DomainObject obj, TaskMonitor monitor)
Add a domain object to this folder.DomainFile
createFile(java.lang.String fileName, java.io.File packFile, TaskMonitor monitor)
Add a new domain file to this folder.GhidraFolder
createFolder(java.lang.String folderName)
Create a subfolder of this folder.void
delete()
Deletes this folder and all of its contentsboolean
equals(java.lang.Object obj)
GhidraFile
getFile(java.lang.String fileName)
Get the domain file in this folder with the given name.GhidraFile[]
getFiles()
Get all domain files in this folder.GhidraFolder
getFolder(java.lang.String folderName)
Return the folder for the given name.GhidraFolder[]
getFolders()
Get DomainFolders in this folder.java.lang.String
getName()
Return this folder's name.DomainFolder
getParent()
Return parent folder or null if this DomainFolder is the root folder.java.lang.String
getPathname()
Returns the path name to the domain object.ProjectFileManager
getProjectData()
Returns the project dataProjectLocator
getProjectLocator()
Returns the local storage location for the project that this DomainFolder belongs to.int
hashCode()
boolean
isEmpty()
Determine if this folder contains any sub-folders or domain files.boolean
isInWritableProject()
Returns true if this file is in a writable project.GhidraFolder
moveTo(DomainFolder newParent)
Move this folder into the newParent folder.void
setActive()
Allows the framework to react to a request to make this folder the "active" one.GhidraFolder
setName(java.lang.String newName)
Set the name on this domain folder.java.lang.String
toString()
-
-
-
Method Detail
-
compareTo
public int compareTo(DomainFolder df)
- Specified by:
compareTo
in interfacejava.lang.Comparable<DomainFolder>
-
getName
public java.lang.String getName()
Description copied from interface:DomainFolder
Return this folder's name.- Specified by:
getName
in interfaceDomainFolder
- Returns:
- the name
-
setName
public GhidraFolder setName(java.lang.String newName) throws InvalidNameException, java.io.IOException
Description copied from interface:DomainFolder
Set the name on this domain folder.- Specified by:
setName
in 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 charactersDuplicateFileException
- if a folder named newName already exists in this files domain folder.FileInUseException
- if any file within this folder or its descendants is in-use / checked-out.java.io.IOException
- thrown if an IO or access error occurs.
-
getProjectLocator
public ProjectLocator getProjectLocator()
Description copied from interface:DomainFolder
Returns the local storage location for the project that this DomainFolder belongs to.- Specified by:
getProjectLocator
in interfaceDomainFolder
- Returns:
- the locator
-
getProjectData
public ProjectFileManager getProjectData()
Description copied from interface:DomainFolder
Returns the project data- Specified by:
getProjectData
in interfaceDomainFolder
- Returns:
- the project data
-
getPathname
public java.lang.String getPathname()
Description copied from interface:DomainFolder
Returns the path name to the domain object.- Specified by:
getPathname
in interfaceDomainFolder
- Returns:
- the path name
-
isInWritableProject
public boolean isInWritableProject()
Description copied from interface:DomainFolder
Returns true if this file is in a writable project.- Specified by:
isInWritableProject
in interfaceDomainFolder
- Returns:
- true if writable
-
getParent
public DomainFolder getParent()
Description copied from interface:DomainFolder
Return parent folder or null if this DomainFolder is the root folder.- Specified by:
getParent
in interfaceDomainFolder
- Returns:
- the parent
-
getFolders
public GhidraFolder[] getFolders()
Description copied from interface:DomainFolder
Get DomainFolders in this folder. This returns cached information and does not force a full refresh.- Specified by:
getFolders
in interfaceDomainFolder
- Returns:
- list of sub-folders
-
getFolder
public GhidraFolder getFolder(java.lang.String folderName)
Description copied from interface:DomainFolder
Return the folder for the given name.- Specified by:
getFolder
in interfaceDomainFolder
- Parameters:
folderName
- of folder to retrieve- Returns:
- folder or null if there is no folder by the given name.
-
isEmpty
public boolean isEmpty()
Description copied from interface:DomainFolder
Determine if this folder contains any sub-folders or domain files.- Specified by:
isEmpty
in interfaceDomainFolder
- Returns:
- true if this folder is empty.
-
getFiles
public GhidraFile[] getFiles()
Description copied from interface:DomainFolder
Get all domain files in this folder. This returns cached information and does not force a full refresh.- Specified by:
getFiles
in interfaceDomainFolder
- Returns:
- list of domain files
-
getFile
public GhidraFile getFile(java.lang.String fileName)
Description copied from interface:DomainFolder
Get the domain file in this folder with the given name.- Specified by:
getFile
in interfaceDomainFolder
- Parameters:
fileName
- 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.
-
createFile
public DomainFile createFile(java.lang.String fileName, DomainObject obj, TaskMonitor monitor) throws InvalidNameException, java.io.IOException, CancelledException
Description copied from interface:DomainFolder
Add a domain object to this folder.- Specified by:
createFile
in interfaceDomainFolder
- Parameters:
fileName
- 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.DuplicateFileException
- thrown if the file name already existsjava.io.IOException
- if IO or access error occursCancelledException
- if the user cancels the create.
-
createFile
public DomainFile createFile(java.lang.String fileName, java.io.File packFile, TaskMonitor monitor) throws InvalidNameException, java.io.IOException, CancelledException
Description copied from interface:DomainFolder
Add a new domain file to this folder.- Specified by:
createFile
in interfaceDomainFolder
- Parameters:
fileName
- 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.DuplicateFileException
- thrown if the file name already existsjava.io.IOException
- if IO or access error occursCancelledException
- if the user cancels the create.
-
createFolder
public GhidraFolder createFolder(java.lang.String folderName) throws InvalidNameException, java.io.IOException
Description copied from interface:DomainFolder
Create a subfolder of this folder.- Specified by:
createFolder
in interfaceDomainFolder
- Parameters:
folderName
- sub-folder name- Returns:
- the folder
- Throws:
InvalidNameException
- if name is an empty string of if it contains characters other than alphanumerics.DuplicateFileException
- if a folder by this name already existsjava.io.IOException
- if IO or access error occurs
-
delete
public void delete() throws java.io.IOException
Description copied from interface:DomainFolder
Deletes this folder and all of its contents- Specified by:
delete
in interfaceDomainFolder
- Throws:
java.io.IOException
- if IO or access error occursFolderNotEmptyException
- Thrown if the subfolder is not empty.
-
moveTo
public GhidraFolder moveTo(DomainFolder newParent) throws java.io.IOException
Description copied from interface:DomainFolder
Move this folder into the newParent folder. If connected to an archive this affects both private and repository folders and files. If not connected, only private folders and files are affected.- Specified by:
moveTo
in 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:
DuplicateFileException
- if a folder with the same name already exists in newParent folder.FileInUseException
- if this folder or one of its descendants contains a file which is in-use / checked-out.java.io.IOException
- thrown if an IO or access error occurs.
-
copyTo
public GhidraFolder copyTo(DomainFolder newParent, TaskMonitor monitor) throws java.io.IOException, CancelledException
Description copied from interface:DomainFolder
Copy this folder into the newParent folder.- Specified by:
copyTo
in interfaceDomainFolder
- Parameters:
newParent
- new parent foldermonitor
- the task monitor- Returns:
- the copied folder
- Throws:
DuplicateFileException
- if a folder or file by this name already exists in the newParent folderjava.io.IOException
- thrown if an IO or access error occurs.CancelledException
- if task monitor cancelled operation.
-
setActive
public void setActive()
Description copied from interface:DomainFolder
Allows the framework to react to a request to make this folder the "active" one.- Specified by:
setActive
in interfaceDomainFolder
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-