Package ghidra.framework.data

# Class LinkedGhidraFolder

java.lang.Object
ghidra.framework.data.LinkedGhidraFolder

All Implemented Interfaces:
  `DomainFolder`, `LinkedDomainFolder`, `Comparable<DomainFolder>`

public class LinkedGhidraFolder extends Object
`LinkedGhidraFolder` provides the base `LinkedDomainFolder` implementation which corresponds to a project folder-link (see `FolderLinkContentHandler`).

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static Icon`
  `FOLDER_LINK_CLOSED_ICON`
  `static Icon`
  `FOLDER_LINK_OPEN_ICON`

  ### Fields inherited from interface ghidra.framework.model.DomainFolder

  `CLOSED_FOLDER_ICON, COPY_SUFFIX, OPEN_FOLDER_ICON, SEPARATOR`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(DomainFolder df)`
  `DomainFolder`
  `copyTo(DomainFolder newParent, TaskMonitor monitor)`
  Copy this folder into the newParent folder.
  `DomainFile`
  `copyToAsLink(DomainFolder newParent)`
  Create a new link-file in the specified newParent which will reference this folder (i.e., linked-folder).
  `DomainFile`
  `createFile(String name, DomainObject obj, TaskMonitor monitor)`
  Add a domain object to this folder.
  `DomainFile`
  `createFile(String name, File packFile, TaskMonitor monitor)`
  Add a new domain file to this folder.
  `DomainFolder`
  `createFolder(String name)`
  Create a subfolder within this folder.
  `void`
  `delete()`
  Deletes this folder, if empty, from the local filesystem
  `DomainFile`
  `getFile(String name)`
  Get the domain file in this folder with the given name.
  `DomainFile[]`
  `getFiles()`
  Get all domain files in this folder.
  `ghidra.framework.data.LinkedGhidraSubFolder`
  `getFolder(String name)`
  Return the folder for the given name.
  `ghidra.framework.data.LinkedGhidraSubFolder[]`
  `getFolders()`
  Get DomainFolders in this folder.
  `Icon`
  `getIcon(boolean isOpen)`
  Get the appropriate icon for this folder
  `DomainFile`
  `getLinkedFileNoError(String name)`
  Get the true file within this linked folder.
  `DomainFolder`
  `getLinkedFolder()`
  Get the real domain folder which corresponds to this linked-folder.
  `String`
  `getLinkedPathname()`
  Get the pathname of this folder within the linked-project/repository
  `URL`
  `getLocalProjectURL()`
  Get a local Ghidra URL for this domain file if available within the associated non-transient local project.
  `String`
  `getName()`
  Return this folder's name.
  `DomainFolder`
  `getParent()`
  Return parent folder or null if this DomainFolder is the root folder.
  `String`
  `getPathname()`
  Returns the full path name to this folder
  `ProjectData`
  `getProjectData()`
  Returns the project data
  `ProjectLocator`
  `getProjectLocator()`
  Returns the local storage location for the project that this DomainFolder belongs to.
  `URL`
  `getProjectURL()`
  Get the Ghidra URL associated with this linked folder's project or repository
  `URL`
  `getSharedProjectURL()`
  Get a remote Ghidra URL for this domain folder if available within an associated shared project repository.
  `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.
  `boolean`
  `isLinked()`
  Determine if this folder corresponds to a linked-folder.
  `DomainFolder`
  `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.
  `DomainFolder`
  `setName(String newName)`
  Set the name on this domain folder.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### FOLDER_LINK_CLOSED_ICON

    public static Icon FOLDER_LINK_CLOSED_ICON

  - ### FOLDER_LINK_OPEN_ICON

    public static Icon FOLDER_LINK_OPEN_ICON

- ## Method Details

  - ### getProjectURL

    public URL getProjectURL()
    Get the Ghidra URL associated with this linked folder's project or repository
    Returns:
      Ghidra URL associated with this linked folder's project or repository

  - ### getLinkedPathname

    public String getLinkedPathname()
    Get the pathname of this folder within the linked-project/repository
    Returns:
      absolute linked folder path within the linked-project/repository

  - ### 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 ProjectData getProjectData()
    Description copied from interface: `DomainFolder`
    Returns the project data
    Specified by:
      `getProjectData` in interface `DomainFolder`
    Returns:
      the project data

  - ### 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

  - ### toString

    public String toString()

  - ### getIcon

    public Icon getIcon(boolean isOpen)
    Description copied from interface: `LinkedDomainFolder`
    Get the appropriate icon for this folder
    Specified by:
      `getIcon` in interface `LinkedDomainFolder`
    Parameters:
      `isOpen` - true if open icon, false for closed
    Returns:
      folder icon

  - ### isLinked

    public boolean isLinked()
    Description copied from interface: `DomainFolder`
    Determine if this folder corresponds to a linked-folder.
    Returns:
      true if folder corresponds to a linked-folder, else false.

  - ### 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

  - ### getName

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

  - ### getLinkedFolder

    public DomainFolder getLinkedFolder() throws IOException
    Description copied from interface: `LinkedDomainFolder`
    Get the real domain folder which corresponds to this linked-folder.
    Specified by:
      `getLinkedFolder` in interface `LinkedDomainFolder`
    Returns:
      domain folder
    Throws:
      `IOException` - if an IO error occurs

  - ### compareTo

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

  - ### setName

    public DomainFolder 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.

  - ### getSharedProjectURL

    public URL getSharedProjectURL()
    Description copied from interface: `DomainFolder`
    Get a remote Ghidra URL for this domain folder if available within an associated shared project repository. URL path will end with "/". A null value will be returned if shared folder does not exist and may also be returned if shared repository is not connected or a connection error occurs.
    Specified by:
      `getSharedProjectURL` in interface `DomainFolder`
    Returns:
      remote Ghidra URL for this folder or null

  - ### getLocalProjectURL

    public URL getLocalProjectURL()
    Description copied from interface: `DomainFolder`
    Get 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:
      `getLocalProjectURL` in interface `DomainFolder`
    Returns:
      local Ghidra URL for this folder or null if transient or not applicable

  - ### getPathname

    public String getPathname()
    Description copied from interface: `DomainFolder`
    Returns the full path name to this folder
    Specified by:
      `getPathname` in interface `DomainFolder`
    Returns:
      the path name

  - ### getFolders

    public ghidra.framework.data.LinkedGhidraSubFolder[] 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 ghidra.framework.data.LinkedGhidraSubFolder getFolder(String name)
    Description copied from interface: `DomainFolder`
    Return the folder for the given name.
    Specified by:
      `getFolder` in interface `DomainFolder`
    Parameters:
      `name` - of folder to retrieve
    Returns:
      folder or null if there is no folder by the given name.

  - ### getFiles

    public DomainFile[] 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

  - ### getLinkedFileNoError

    public DomainFile getLinkedFileNoError(String name)
    Get the true file within this linked folder.
    Parameters:
      `name` - file name
    Returns:
      file or null if not found or error occurs

  - ### getFile

    public DomainFile getFile(String name)
    Description copied from interface: `DomainFolder`
    Get the domain file in this folder with the given name.
    Specified by:
      `getFile` in interface `DomainFolder`
    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: `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.

  - ### createFile

    public DomainFile createFile(String name, 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:
      `name` - 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 name, 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:
      `name` - 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 DomainFolder createFolder(String name) throws InvalidNameException, IOException
    Description copied from interface: `DomainFolder`
    Create a subfolder within this folder.
    Specified by:
      `createFolder` in interface `DomainFolder`
    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.
      `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, if empty, from the local filesystem
    Specified by:
      `delete` in interface `DomainFolder`
    Throws:
      `IOException` - if IO or access error occurs
      `FolderNotEmptyException` - Thrown if this folder is not empty.

  - ### moveTo

    public DomainFolder moveTo(DomainFolder newParent) throws IOException
    Description copied from interface: `DomainFolder`
    Move 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:
      `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 DomainFolder 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 new 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`
    Create a new link-file in the specified newParent which will reference this folder (i.e., linked-folder). 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 folder 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 where link-file is to be created
    Returns:
      newly created domain file (i.e., link-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`