Class FileSystemFactoryMgr
- java.lang.Object
-
- ghidra.formats.gfilesystem.factory.FileSystemFactoryMgr
-
public class FileSystemFactoryMgr extends java.lang.Object
Statically scoped mugger that handles the dirty work of probing for and creatingGFileSystem
instances.Auto-discovers all
GFileSystem
instances in the classpath that have aFileSystemInfo
annotation.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getAllFilesystemNames()
Returns a list of all registered filesystem implementation descriptions.java.lang.String
getFileSystemType(java.lang.Class<? extends GFileSystem> fsClass)
Returns the file system type of the specifiedGFileSystem
class.static FileSystemFactoryMgr
getInstance()
GFileSystem
mountFileSystem(java.lang.String fsType, ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor)
Creates a newGFileSystem
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 supportedGFileSystem
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 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 Detail
-
getInstance
public static FileSystemFactoryMgr getInstance()
- Returns:
- The single global
FileSystemFactoryMgr
instance.
-
getAllFilesystemNames
public java.util.List<java.lang.String> getAllFilesystemNames()
Returns a list of all registered filesystem implementation descriptions.- Returns:
- list of strings
-
getFileSystemType
public java.lang.String getFileSystemType(java.lang.Class<? extends GFileSystem> fsClass)
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(java.lang.String fsType, ByteProvider byteProvider, FileSystemService fsService, TaskMonitor monitor) throws java.io.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:
java.io.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 java.io.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:
java.io.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 java.io.IOException, CancelledException
Probes the specified file for a supportedGFileSystem
implementation, and if found, creates a new filesystem instance.- Parameters:
containerFSRL
-FSRL
of the containing file.containerFile
-File
the containing file.fsService
- 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:
java.io.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 java.io.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:
java.io.IOException
- if error accessing the containing fileCancelledException
- if the user cancels the operation
-
-