Class GhidraFolder

java.lang.Object
ghidra.framework.data.GhidraFolder
All Implemented Interfaces:
DomainFolder, Comparable<DomainFolder>
Direct Known Subclasses:
RootGhidraFolder

public class GhidraFolder extends Object implements DomainFolder
  • Method Details

    • compareTo

      public int compareTo(DomainFolder df)
      Specified by:
      compareTo in interface Comparable<DomainFolder>
    • getName

      public String getName()
      Description copied from interface: DomainFolder
      Return this folder's name.
      Specified by:
      getName in interface DomainFolder
      Returns:
      the name
    • setName

      public GhidraFolder setName(String newName) throws InvalidNameException, IOException
      Description copied from interface: DomainFolder
      Set the name on this domain folder.
      Specified by:
      setName in interface DomainFolder
      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 characters
      DuplicateFileException - 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.
      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 interface DomainFolder
      Returns:
      the locator
    • getProjectData

      public ProjectFileManager getProjectData()
      Description copied from interface: DomainFolder
      Returns the project data
      Specified by:
      getProjectData in interface DomainFolder
      Returns:
      the project data
    • getPathname

      public String getPathname()
      Description copied from interface: DomainFolder
      Returns the path name to the domain object.
      Specified by:
      getPathname in interface DomainFolder
      Returns:
      the path name
    • getSharedProjectURL

      public URL getSharedProjectURL()
      Description copied from interface: DomainFolder
      Get a remote Ghidra URL for this domain folder within the associated shared project repository. URL path will end with "/". A null value will be returned if not associated with a shared project.
      Specified by:
      getSharedProjectURL in interface DomainFolder
      Returns:
      remote Ghidra URL for this folder or null
    • isInWritableProject

      public boolean isInWritableProject()
      Description copied from interface: DomainFolder
      Returns true if this file is in a writable project.
      Specified by:
      isInWritableProject in interface DomainFolder
      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 interface DomainFolder
      Returns:
      the parent
    • getFolders

      public GhidraFolder[] getFolders()
      Description copied from interface: DomainFolder
      Get DomainFolders in this folder. This may return cached information and does not force a full refresh.
      Specified by:
      getFolders in interface DomainFolder
      Returns:
      list of sub-folders
    • getFolder

      public GhidraFolder getFolder(String folderName)
      Description copied from interface: DomainFolder
      Return the folder for the given name.
      Specified by:
      getFolder in interface DomainFolder
      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 interface DomainFolder
      Returns:
      true if this folder is empty.
    • getFiles

      public GhidraFile[] getFiles()
      Description copied from interface: DomainFolder
      Get all domain files in this folder. This may return cached information and does not force a full refresh.
      Specified by:
      getFiles in interface DomainFolder
      Returns:
      list of domain files
    • getFile

      public GhidraFile getFile(String fileName)
      Description copied from interface: DomainFolder
      Get the domain file in this folder with the given name.
      Specified by:
      getFile in interface DomainFolder
      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(String fileName, DomainObject obj, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException
      Description copied from interface: DomainFolder
      Add a domain object to this folder.
      Specified by:
      createFile in interface DomainFolder
      Parameters:
      fileName - domain file name
      obj - domain object to be stored
      monitor - 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 exists
      IOException - if IO or access error occurs
      CancelledException - if the user cancels the create.
    • createFile

      public DomainFile createFile(String fileName, File packFile, TaskMonitor monitor) throws InvalidNameException, IOException, CancelledException
      Description copied from interface: DomainFolder
      Add a new domain file to this folder.
      Specified by:
      createFile in interface DomainFolder
      Parameters:
      fileName - domain file name
      packFile - packed file containing domain file data
      monitor - 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 exists
      IOException - if IO or access error occurs
      CancelledException - if the user cancels the create.
    • createFolder

      public GhidraFolder createFolder(String folderName) throws InvalidNameException, IOException
      Description copied from interface: DomainFolder
      Create a subfolder of this folder.
      Specified by:
      createFolder in interface DomainFolder
      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 exists
      IOException - if IO or access error occurs
    • delete

      public void delete() throws IOException
      Description copied from interface: DomainFolder
      Deletes this folder and all of its contents
      Specified by:
      delete in interface DomainFolder
      Throws:
      IOException - if IO or access error occurs
      FolderNotEmptyException - Thrown if the subfolder is not empty.
    • moveTo

      public GhidraFolder moveTo(DomainFolder newParent) throws 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 interface DomainFolder
      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.
      IOException - thrown if an IO or access error occurs.
    • copyTo

      public GhidraFolder copyTo(DomainFolder newParent, TaskMonitor monitor) throws IOException, CancelledException
      Description copied from interface: DomainFolder
      Copy this folder into the newParent folder.
      Specified by:
      copyTo in interface DomainFolder
      Parameters:
      newParent - new parent folder
      monitor - the task monitor
      Returns:
      the copied folder
      Throws:
      DuplicateFileException - if a folder or file by this name already exists in the newParent folder
      IOException - thrown if an IO or access error occurs.
      CancelledException - if task monitor cancelled operation.
    • copyToAsLink

      public DomainFile copyToAsLink(DomainFolder newParent) throws IOException
      Description copied from interface: DomainFolder
      Copy this folder into the newParent folder as a link file. Restrictions:
      • Specified newParent must reside within a different project since internal linking is not currently supported.
      If this folder is associated with a temporary transient project (i.e., not a locally managed project) the generated link will refer to the remote file with a remote Ghidra URL, otherwise a local project storage path will be used.
      Specified by:
      copyToAsLink in interface DomainFolder
      Parameters:
      newParent - new parent folder
      Returns:
      newly created domain file or null if link use not supported.
      Throws:
      IOException - if an IO or access error occurs.
    • 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 interface DomainFolder
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object