Package ghidra.formats.gfilesystem
Class GFileSystemBase
java.lang.Object
ghidra.formats.gfilesystem.GFileSystemBase
- All Implemented Interfaces:
GFileSystem,ExtensionPoint,Closeable,AutoCloseable,Iterable<GFile>
This is the original GFileSystem implementation abstract base class, with most of the
initially implemented filesystem types extending this class.
The new GFileSystem interface is being retro-fitted into this equation to support better probing and factory syntax, and new implementations should be based on the interface instead of extending this abstract class.
NOTE: ALL GFileSystem sub-CLASSES MUST END IN "FileSystem". If not, the ClassSearcher will not find them. Yes, it is an implementation detail.
GFileSystemBase instances are constructed when probing a container file and are queried
with isValid(TaskMonitor) to determine if the container file is handled
by the GFileSystemBase subclass.
The ByteProvider given to the constructor is not considered 'owned' by
the GFileSystemBase instance until after it passes the isValid
check and is opened.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected FileSystemServiceprotected ByteProviderprotected GFileImpl -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGFileSystemBase(String fileSystemName, ByteProvider provider) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the file system.protected voidWrites the given bytes to a tempfile in the temp directory.protected Comparator<String> Override to specify a file-system specific name comparator.getFSRL()File system's FSRLgetListing(GFile directory) Returns a list offilesthat reside in the specified directory on this filesystem.final StringgetName()Returns the name of this file system.Returns theref managerthat is responsible for creating and releasingrefsto this filesystem.booleanisClosed()Returns true if the filesystem has beenclosedabstract booleanisValid(TaskMonitor monitor) Returns true if this file system implementation can handle the bytes provided.Retrieves aGFilefrom this filesystem based on its full path and filename, using this filesystem's default name comparison logic (eg.lookup(String path, Comparator<String> nameComp) Retrieves aGFilefrom this filesystem based on its full path and filename, using the specified name comparison logic (eg.abstract voidopen(TaskMonitor monitor) Opens the file system.voidsetFilesystemService(FileSystemService fsService) voidtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ghidra.formats.gfilesystem.GFileSystem
files, files, files, files, getByteProvider, getDescription, getFileAttributes, getFileCount, getInputStream, getRootDir, getType, isStatic, iterator, resolveSymlinksMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
fileSystemName
-
root
-
provider
-
fsService
-
-
Constructor Details
-
GFileSystemBase
-
-
Method Details
-
toString
-
getFSRL
Description copied from interface:GFileSystemFile system's FSRL- Specified by:
getFSRLin interfaceGFileSystem- Returns:
FSRLRootof this filesystem.
-
setFSRL
-
setFilesystemService
-
isValid
Returns true if this file system implementation can handle the bytes provided. This method should perform the minimal amount of checks required to determine validity. Keep it quick and tight!- Parameters:
monitor- a task monitor- Returns:
- true if valid for the byte provider
- Throws:
IOException- if an I/O error occurs
-
open
public abstract void open(TaskMonitor monitor) throws IOException, CryptoException, CancelledException Opens the file system.- Throws:
IOException- if an I/O error occursCryptoException- if an encryption error occursCancelledException
-
close
Closes the file system. All resources should be released. (programs, temporary files, etc.)- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if an I/O error occurs
-
isClosed
public boolean isClosed()Description copied from interface:GFileSystemReturns true if the filesystem has beenclosed- Specified by:
isClosedin interfaceGFileSystem- Returns:
- boolean true if the filesystem has been closed.
-
getName
Returns the name of this file system.- Specified by:
getNamein interfaceGFileSystem- Returns:
- the name of this file system
-
getListing
Description copied from interface:GFileSystemReturns a list offilesthat reside in the specified directory on this filesystem.- Specified by:
getListingin interfaceGFileSystem- Parameters:
directory- NULL means root of filesystem.- Returns:
ListofGFileinstances of file in the requested directory.- Throws:
IOException- if IO problem.
-
debug
Writes the given bytes to a tempfile in the temp directory.- Parameters:
bytes- the bytes to writefileName- the prefix of the temp file name
-
getFilenameComparator
Override to specify a file-system specific name comparator.- Returns:
Comparatorsuch asString.compareTo(String)orString.compareToIgnoreCase(String)
-
lookup
Description copied from interface:GFileSystemRetrieves aGFilefrom this filesystem based on its full path and filename, using this filesystem's default name comparison logic (eg. case sensitive vs insensitive).- Specified by:
lookupin interfaceGFileSystem- Parameters:
path- string path and filename of a file located in this filesystem. Usenullor "/" to retrieve the root directory- Returns:
GFileinstance of requested file, null if not found.- Throws:
IOException- if IO error when looking up file.
-
lookup
Description copied from interface:GFileSystemRetrieves aGFilefrom this filesystem based on its full path and filename, using the specified name comparison logic (eg. case sensitive vs insensitive).- Specified by:
lookupin interfaceGFileSystem- Parameters:
path- string path and filename of a file located in this filesystem. Usenullor "/" to retrieve the root directorynameComp- string comparator used to compare filenames. Usenullto specify the file system's native comparison logic.- Returns:
GFileinstance of requested file, null if not found.- Throws:
IOException- if IO error when looking up file.
-
getRefManager
Description copied from interface:GFileSystemReturns theref managerthat is responsible for creating and releasingrefsto this filesystem.- Specified by:
getRefManagerin interfaceGFileSystem- Returns:
FileSystemRefManagerthat manages references to this filesystem.
-