Package ghidra.plugin.importer

# Class ImporterUtilities

java.lang.Object
ghidra.plugin.importer.ImporterUtilities

public class ImporterUtilities extends Object
Utilities for importing files.

Note: if a method takes a `TaskMonitor`, then that method should only be called from a background task.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final GhidraFileFilter`
  `CONTAINER_FILES_FILTER`
  File extension filter for well known 'container' files for GhidraFileChoosers.
  `static final GhidraFileFilter`
  `LOADABLE_FILES_FILTER`
  File extension filter for well known 'loadable' files for GhidraFileChoosers.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ImporterUtilities()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `addContentToProgram(PluginTool tool, Program program, FSRL fsrl, LoadSpec loadSpec, List<Option> options, TaskMonitor monitor)`
  `static LoadSpec`
  `getLoadSpec(Program program)`
  Get's the `LoadSpec` that was used to import the given `Program`
  `static void`
  `importSingleFile(PluginTool tool, ProgramManager programManager, FSRL fsrl, String projectRootPath, boolean mirrorFsLayout, LoadSpec loadSpec, String importName, List<Option> options, TaskMonitor monitor)`
  Perform file import and open using optional programManager
  `static void`
  `showAddToProgramDialog(FSRL fsrl, Program program, PluginTool tool, TaskMonitor monitor)`
  `static void`
  `showImportDialog(PluginTool tool, ProgramManager programManager, FSRL fsrl, DomainFolder destinationFolder, String suggestedPath)`
  Displays the appropriate import dialog for the specified `file`.
  `static void`
  `showImportDialog(PluginTool tool, ProgramManager programManager, FSRL fsrl, DomainFolder destinationFolder, String suggestedPath, TaskMonitor monitor)`
  Displays the appropriate import dialog for the specified `file`.
  `static void`
  `showImportSingleFileDialog(FSRL fsrl, DomainFolder destinationFolder, String suggestedPath, PluginTool tool, ProgramManager programManager, TaskMonitor monitor)`
  Constructs a `ImporterDialog` and shows it in the swing thread.
  `static void`
  `showLoadLibrariesDialog(Program program, PluginTool tool, TaskMonitor monitor)`
  Constructs a `LoadLibrariesOptionsDialog` and shows it in the swing thread.

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

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

- ## Field Details

  - ### LOADABLE_FILES_FILTER

    public static final GhidraFileFilter LOADABLE_FILES_FILTER
    File extension filter for well known 'loadable' files for GhidraFileChoosers.

  - ### CONTAINER_FILES_FILTER

    public static final GhidraFileFilter CONTAINER_FILES_FILTER
    File extension filter for well known 'container' files for GhidraFileChoosers.

- ## Constructor Details

  - ### ImporterUtilities

    public ImporterUtilities()

- ## Method Details

  - ### showImportDialog

    public static void showImportDialog(PluginTool tool, ProgramManager programManager, FSRL fsrl, DomainFolder destinationFolder, String suggestedPath)
    Displays the appropriate import dialog for the specified `file`.

    If the file is a container of other files, a batch import dialog will be used, otherwise the normal single file import dialog will be shown.

    Parameters:
      `tool` - `PluginTool` will be used as the parent tool for dialogs
      `programManager` - optional `ProgramManager` instance to use to open imported binaries with, or null
      `fsrl` - `FSRL` of the file to import
      `destinationFolder` - `DomainFolder` destination folder where the imported file will default to. (the user will be able to choose a different location)
      `suggestedPath` - optional string path that will automatically be pre-pended to the destination filename

  - ### showImportDialog

    public static void showImportDialog(PluginTool tool, ProgramManager programManager, FSRL fsrl, DomainFolder destinationFolder, String suggestedPath, TaskMonitor monitor)
    Displays the appropriate import dialog for the specified `file`.

    If the file is a container of other files, a batch import dialog will be used, otherwise the normal single file import dialog will be shown.]

    If you are not in a monitored task, then call `showImportDialog(PluginTool, ProgramManager, FSRL, DomainFolder, String)`.

    Parameters:
      `tool` - `PluginTool` will be used as the parent tool for dialogs
      `programManager` - optional `ProgramManager` instance to use to open imported binaries with, or null
      `fsrl` - `FSRL` of the file to import
      `destinationFolder` - `DomainFolder` destination folder where the imported file will default to. (the user will be able to choose a different location)
      `suggestedPath` - optional string path that will automatically be pre-pended to the destination filename
      `monitor` - the task monitor to use for monitoring; cannot be null

  - ### showAddToProgramDialog

    public static void showAddToProgramDialog(FSRL fsrl, Program program, PluginTool tool, TaskMonitor monitor)

  - ### showLoadLibrariesDialog

    public static void showLoadLibrariesDialog(Program program, PluginTool tool, TaskMonitor monitor)
    Constructs a `LoadLibrariesOptionsDialog` and shows it in the swing thread. If the given `Program` does not support library loading, a warning message will be shown instead.
    Parameters:
      `program` - The `Program`
      `tool` - The `PluginTool`
      `monitor` - `TaskMonitor`

  - ### showImportSingleFileDialog

    public static void showImportSingleFileDialog(FSRL fsrl, DomainFolder destinationFolder, String suggestedPath, PluginTool tool, ProgramManager programManager, TaskMonitor monitor)
    Constructs a `ImporterDialog` and shows it in the swing thread.
    Parameters:
      `fsrl` - the file system resource locater (can be a simple file or an element of a more complex file such as a zip file)
      `destinationFolder` - the default destination folder for the imported file. Can be null
      `suggestedPath` - optional string path that will automatically be pre-pended to the destination filename
      `tool` - the parent UI component
      `programManager` - optional `ProgramManager` instance to open the imported file in
      `monitor` - `TaskMonitor`

  - ### importSingleFile

    public static void importSingleFile(PluginTool tool, ProgramManager programManager, FSRL fsrl, String projectRootPath, boolean mirrorFsLayout, LoadSpec loadSpec, String importName, List<Option> options, TaskMonitor monitor)
    Perform file import and open using optional programManager
    Parameters:
      `tool` - tool to which popup dialogs should be associated
      `programManager` - program manager to open imported file with or null
      `fsrl` - import file location
      `projectRootPath` - The project folder path that all imported things will be saved relative to. If `null`, "/" will be used.
      `mirrorFsLayout` - True if the filesystem layout should be mirrored when loading; otherwise, false
      `loadSpec` - import `LoadSpec`
      `importName` - The import name. Path information that appears at the beginning the name will be appended to the `projectRootPath` during the saving process.
      `options` - import options
      `monitor` - task monitor

  - ### addContentToProgram

    public static void addContentToProgram(PluginTool tool, Program program, FSRL fsrl, LoadSpec loadSpec, List<Option> options, TaskMonitor monitor)

  - ### getLoadSpec

    public static LoadSpec getLoadSpec(Program program)
    Get's the `LoadSpec` that was used to import the given `Program`
    Parameters:
      `program` - The `Program`
    Returns:
      The `LoadSpec` that was used to import the given `Program`, or null if it could not be determined