Class GhidraURL

java.lang.Object
ghidra.framework.protocol.ghidra.GhidraURL

public class GhidraURL extends Object
  • Field Details

  • Method Details

    • localProjectExists

      public static boolean localProjectExists(URL url)
      Determine if the specified URL refers to a local project and it exists.
      Parameters:
      url -
      Returns:
      true if specified URL refers to a local project and it exists.
    • isLocalProjectURL

      public static boolean isLocalProjectURL(URL url)
      Determine if the specified URL is a local project URL. No checking is performed as to the existence of the project.
      Parameters:
      url -
      Returns:
      true if specified URL refers to a local project (ghidra:/path/projectName...)
    • getProjectName

      public static String getProjectName(URL localProjectURL)
      Get the project name which corresponds to the specified local project URL.
      Parameters:
      localProjectURL - local Ghidra project URL
      Returns:
      project name
      Throws:
      IllegalArgumentException - URL is not a valid local project URL
    • getProjectLocation

      public static String getProjectLocation(URL localProjectURL)
      Get the project location path which corresponds to the specified local project URL.
      Parameters:
      localProjectURL - local Ghidra project URL
      Returns:
      project location path
      Throws:
      IllegalArgumentException - URL is not a valid local project URL
    • getProjectStorageLocator

      public static ProjectLocator getProjectStorageLocator(URL localProjectURL)
      Get the project locator which corresponds to the specified local project URL.
      Parameters:
      localProjectURL - local Ghidra project URL
      Returns:
      project locator
      Throws:
      IllegalArgumentException - URL is not a valid local project URL
    • isServerRepositoryURL

      public static boolean isServerRepositoryURL(URL url)
      Determine if the specified URL is any type of server "repository" URL. No checking is performed as to the existence of the server or repository.
      Parameters:
      url -
      Returns:
      true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
    • isServerURL

      public static boolean isServerURL(URL url)
      Determine if the specified URL is any type of server URL. No checking is performed as to the existence of the server or repository.
      Parameters:
      url -
      Returns:
      true if specified URL refers to a Ghidra server repository (ghidra://host/repositoryNAME/path...)
    • toURL

      public static URL toURL(String projectPathOrURL)
      Create a Ghidra URL from a string form of Ghidra URL or local project path. This method can consume strings produced by the getDisplayString method.
      Parameters:
      projectPathOrURL - project path (<absolute-directory>/<project-name>)
      Returns:
      local Ghidra project URL
      Throws:
      IllegalArgumentException - invalid path or URL specified
      See Also:
    • getNormalizedURL

      public static URL getNormalizedURL(URL url)
      Get a normalized URL which eliminates use of host names and additional URL refs which may prevent direct comparison.
      Parameters:
      url -
      Returns:
      normalized url
    • getDisplayString

      public static String getDisplayString(URL url)
      Generate preferred display string for Ghidra URLs. Form can be parsed by the toURL method.
      Parameters:
      url -
      Returns:
      See Also:
    • makeURL

      public static URL makeURL(File projectMarkerFile)
      Create a local project URL for a specified project marker file.
      Parameters:
      projectMarkerFile - project marker file
      Returns:
      local project URL
    • makeURL

      public static URL makeURL(String dirPath, String projectName)
      Create a URL which refers to a local Ghidra project
      Parameters:
      dirPath - absolute path of project location directory
      projectName - name of project
      Returns:
      local Ghidra project URL
    • makeURL

      public static URL makeURL(String host, int port, String repositoryName, String repositoryPath)
      Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.
      Parameters:
      host - server host name/address
      port - optional server port (a value <= 0 refers to the default port)
      repositoryName - repository name
      repositoryPath - absolute folder or file path within repository. Folder paths should end with a '/' character.
      Returns:
      Ghidra Server repository content URL
    • makeURL

      public static URL makeURL(String host, int port, String repositoryName, String repositoryPath, String fileName, String ref)
      Create a URL which refers to Ghidra Server repository content. Path may correspond to either a file or folder.
      Parameters:
      host - server host name/address
      port - optional server port (a value <= 0 refers to the default port)
      repositoryName - repository name
      repositoryPath - absolute folder path within repository.
      fileName - name of a file contained within the specified repository/path
      ref - optional URL ref or null Folder paths should end with a '/' character.
      Returns:
      Ghidra Server repository content URL
    • makeURL

      public static URL makeURL(String host, int port, String repositoryName)
      Create a URL which refers to Ghidra Server repository and its root folder
      Parameters:
      host - server host name/address
      port - optional server port (a value <= 0 refers to the default port)
      repositoryName - repository name
      Returns:
      Ghidra Server repository URL