Package ghidra.formats.gfilesystem.factory

# Class FileSystemFactoryMgr

java.lang.Object
ghidra.formats.gfilesystem.factory.FileSystemFactoryMgr

public class FileSystemFactoryMgr extends Object
Statically scoped mugger that handles the dirty work of probing for and creating `GFileSystem` instances.

Auto-discovers all `GFileSystem` instances in the classpath that have a `FileSystemInfo` annotation.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `List<String>`
  `getAllFilesystemNames()`
  Returns a list of all registered filesystem implementation descriptions.
  `String`
  `getFileSystemType(Class<? extends GFileSystem> fsClass)`
  Returns the file system type of the specified `GFileSystem` class.
  `static FileSystemFactoryMgr`
  `getInstance()`
  `GFileSystem`
  `mountFileSystem(String fsType, ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor)`
  Creates a new `GFileSystem` instance when the filesystem type is already known, consuming the specified ByteProvider.
  `GFileSystem`
  `probe(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, int priorityFilter, TaskMonitor monitor)`
  Probes the specified file for a supported `GFileSystem` implementation, and if found, creates a new filesystem instance.
  `GFileSystem`
  `probe(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, TaskMonitor monitor)`
  Probes the specified file for a supported `GFileSystem` implementation, and if found, creates a new filesystem instance.
  `boolean`
  `test(ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor)`
  Returns true if the specified file contains a supported `GFileSystem`.

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

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

- ## Method Details

  - ### getInstance

    public static FileSystemFactoryMgr getInstance()

    Returns:
      The single global `FileSystemFactoryMgr` instance.

  - ### getAllFilesystemNames

    public List<String> getAllFilesystemNames()
    Returns a list of all registered filesystem implementation descriptions.
    Returns:
      list of strings

  - ### getFileSystemType

    public String getFileSystemType(Class<? extends GFileSystem> fsClass)
    Returns the file system type of the specified `GFileSystem` class.
    Parameters:
      `fsClass` - Class to inspect
    Returns:
      String file system type, from the `FileSystemInfo.type()` annotation.

  - ### mountFileSystem

    public GFileSystem mountFileSystem(String fsType, ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor) throws IOException, CancelledException
    Creates a new `GFileSystem` instance when the filesystem type is already known, consuming the specified ByteProvider.

    Parameters:
      `fsType` - filesystem type string, ie. "file", "zip".
      `byteProvider` - `ByteProvider`, will be owned by the new file system
      `fsService` - reference to the `FileSystemService` instance.
      `monitor` - `TaskMonitor` to use for canceling and updating progress.
    Returns:
      new `GFileSystem` instance.
    Throws:
      `IOException` - if error when opening the filesystem or unknown fsType.
      `CancelledException` - if the user canceled the operation.

  - ### test

    public boolean test(ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor) throws IOException, CancelledException
    Returns true if the specified file contains a supported `GFileSystem`.

    Parameters:
      `byteProvider` -
      `fsService` - reference to the `FileSystemService` instance.
      `monitor` - `TaskMonitor` to use for canceling and updating progress.
    Returns:
      `true` if the file seems to contain a filesystem, `false` if it does not.
    Throws:
      `IOException` - if error when accessing the containing file
      `CancelledException` - if the user canceled the operation

  - ### probe

    public GFileSystem probe(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, TaskMonitor monitor) throws IOException, CancelledException
    Probes the specified file for a supported `GFileSystem` implementation, and if found, creates a new filesystem instance.

    Parameters:
      `byteProvider` - container `ByteProvider`, will be owned by the new filesystem
      `fsService` - reference to the `FileSystemService` instance.
      `conflictResolver` - `conflict resolver` to use when more than one `GFileSystem` implementation can handle the specified file.
      `monitor` - `TaskMonitor` to use for canceling and updating progress.
    Returns:
      new `GFileSystem` instance or null not supported.
    Throws:
      `IOException` - if error accessing the containing file
      `CancelledException` - if the user cancels the operation

  - ### probe

    public GFileSystem probe(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, int priorityFilter, TaskMonitor monitor) throws IOException, CancelledException
    Probes the specified file for a supported `GFileSystem` implementation, and if found, creates a new filesystem instance. The ByteProvider is owned by the new file system.

    Parameters:
      `byteProvider` - container `ByteProvider`, will be owned by the new filesystem
      `fsService` - reference to the `FileSystemService` instance.
      `conflictResolver` - `conflict resolver` to use when more than one `GFileSystem` implementation can handle the specified file.
      `priorityFilter` - limits the probe to filesystems that have a `FileSystemInfo.priority()` greater than or equal to this value. Use `FileSystemInfo.PRIORITY_LOWEST` to include all filesystem implementations.
      `monitor` - `TaskMonitor` to use for canceling and updating progress.
    Returns:
      new `GFileSystem` instance or null not supported.
    Throws:
      `IOException` - if error accessing the containing file
      `CancelledException` - if the user cancels the operation