Class FileSystemFactoryMgr
java.lang.Object
ghidra.formats.gfilesystem.factory.FileSystemFactoryMgr
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 TypeMethodDescriptionReturns a list of all registered filesystem implementation descriptions.getFileSystemType
(Class<? extends GFileSystem> fsClass) Returns the file system type of the specifiedGFileSystem
class.static FileSystemFactoryMgr
mountFileSystem
(String fsType, ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor) Creates a newGFileSystem
instance when the filesystem type is already known, consuming the specified ByteProvider.probe
(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, int priorityFilter, TaskMonitor monitor) Probes the specified file for a supportedGFileSystem
implementation, and if found, creates a new filesystem instance.probe
(ByteProvider byteProvider, FileSystemService fsService, FileSystemProbeConflictResolver conflictResolver, TaskMonitor monitor) Probes the specified file for a supportedGFileSystem
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 supportedGFileSystem
.
-
Method Details
-
getInstance
- Returns:
- The single global
FileSystemFactoryMgr
instance.
-
getAllFilesystemNames
Returns a list of all registered filesystem implementation descriptions.- Returns:
- list of strings
-
getFileSystemType
Returns the file system type of the specifiedGFileSystem
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 newGFileSystem
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 systemfsService
- reference to theFileSystemService
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 supportedGFileSystem
.- Parameters:
byteProvider
-fsService
- reference to theFileSystemService
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 fileCancelledException
- 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 supportedGFileSystem
implementation, and if found, creates a new filesystem instance.- Parameters:
byteProvider
- containerByteProvider
, will be owned by the new filesystemfsService
- reference to theFileSystemService
instance.conflictResolver
-conflict resolver
to use when more than oneGFileSystem
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 fileCancelledException
- 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 supportedGFileSystem
implementation, and if found, creates a new filesystem instance. The ByteProvider is owned by the new file system.- Parameters:
byteProvider
- containerByteProvider
, will be owned by the new filesystemfsService
- reference to theFileSystemService
instance.conflictResolver
-conflict resolver
to use when more than oneGFileSystem
implementation can handle the specified file.priorityFilter
- limits the probe to filesystems that have aFileSystemInfo.priority()
greater than or equal to this value. UseFileSystemInfo.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 fileCancelledException
- if the user cancels the operation
-