Class GFileSystemBase
- java.lang.Object
- 
- ghidra.formats.gfilesystem.GFileSystemBase
 
- 
- All Implemented Interfaces:
- GFileSystem,- ExtensionPoint,- java.io.Closeable,- java.lang.AutoCloseable
 
 public abstract class GFileSystemBase extends java.lang.Object implements GFileSystem 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 ByteProvidergiven to the constructor is not considered 'owned' by the GFileSystemBase instance until after it passes theisValidcheck and isopened.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface ghidra.util.classfinder.ExtensionPointExtensionPoint.Exclude, ExtensionPoint.Util
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected java.lang.StringfileSystemNameprotected FileSystemServicefsServiceprotected ByteProviderproviderprotected GFileImplroot
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedGFileSystemBase(java.lang.String fileSystemName, ByteProvider provider)
 - 
Method SummaryAll Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()Closes the file system.protected voiddebug(byte[] bytes, java.lang.String fileName)Writes the given bytes to a tempfile in the temp directory.protected abstract java.io.InputStreamgetData(GFile file, TaskMonitor monitor)Legacy implementation ofgetInputStream(GFile, TaskMonitor).FSRLRootgetFSRL()File system's FSRLjava.io.InputStreamgetInputStream(GFile file, TaskMonitor monitor)Returns anInputStreamthat contains the contents of the specifiedGFile.abstract java.util.List<GFile>getListing(GFile directory)Returns a list offilesthat reside in the specified directory on this filesystem.java.lang.StringgetName()Returns the name of this file system.FileSystemRefManagergetRefManager()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.GFilelookup(java.lang.String path)Retrieves aGFilefrom this filesystem based on its full path and filename.abstract voidopen(TaskMonitor monitor)Opens the file system.voidsetFilesystemService(FileSystemService fsService)voidsetFSRL(FSRLRoot fsrl)java.lang.StringtoString()- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface ghidra.formats.gfilesystem.GFileSystemgetDescription, getFileCount, getInfo, getType, isStatic
 
- 
 
- 
- 
- 
Field Detail- 
fileSystemNameprotected java.lang.String fileSystemName 
 - 
rootprotected GFileImpl root 
 - 
providerprotected ByteProvider provider 
 - 
fsServiceprotected FileSystemService fsService 
 
- 
 - 
Constructor Detail- 
GFileSystemBaseprotected GFileSystemBase(java.lang.String fileSystemName, ByteProvider provider)
 
- 
 - 
Method Detail- 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 - 
getFSRLpublic FSRLRoot getFSRL() Description copied from interface:GFileSystemFile system's FSRL- Specified by:
- getFSRLin interface- GFileSystem
- Returns:
- FSRLRootof this filesystem.
 
 - 
setFSRLpublic void setFSRL(FSRLRoot fsrl) 
 - 
setFilesystemServicepublic void setFilesystemService(FileSystemService fsService) 
 - 
isValidpublic abstract boolean isValid(TaskMonitor monitor) throws java.io.IOException 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:
- java.io.IOException- if an I/O error occurs
 
 - 
openpublic abstract void open(TaskMonitor monitor) throws java.io.IOException, CryptoException, CancelledException Opens the file system.- Throws:
- java.io.IOException- if an I/O error occurs
- CryptoException- if an encryption error occurs
- CancelledException
 
 - 
closepublic void close() throws java.io.IOExceptionCloses the file system. All resources should be released. (programs, temporary files, etc.)- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Throws:
- java.io.IOException- if an I/O error occurs
 
 - 
isClosedpublic boolean isClosed() Description copied from interface:GFileSystemReturns true if the filesystem has beenclosed- Specified by:
- isClosedin interface- GFileSystem
- Returns:
- boolean true if the filesystem has been closed.
 
 - 
getNamepublic final java.lang.String getName() Returns the name of this file system.- Specified by:
- getNamein interface- GFileSystem
- Returns:
- the name of this file system
 
 - 
getListingpublic abstract java.util.List<GFile> getListing(GFile directory) throws java.io.IOException Description copied from interface:GFileSystemReturns a list offilesthat reside in the specified directory on this filesystem.- Specified by:
- getListingin interface- GFileSystem
- Parameters:
- directory- NULL means root of filesystem.
- Returns:
- Listof- GFileinstances of file in the requested directory.
- Throws:
- java.io.IOException- if IO problem.
 
 - 
getDataprotected abstract java.io.InputStream getData(GFile file, TaskMonitor monitor) throws java.io.IOException, CancelledException, CryptoException Legacy implementation ofgetInputStream(GFile, TaskMonitor).- Parameters:
- file-- GFileto get an InputStream for
- monitor-- TaskMonitorto watch and update progress
- Returns:
- new InputStreamcontains the contents of the file or NULL if the file doesn't have data.
- Throws:
- java.io.IOException- if IO problem
- CancelledException- if user cancels.
- CryptoException- if crypto problem.
 
 - 
getInputStreampublic java.io.InputStream getInputStream(GFile file, TaskMonitor monitor) throws CancelledException, java.io.IOException Description copied from interface:GFileSystemReturns anInputStreamthat contains the contents of the specifiedGFile.The caller is responsible for closing the stream. - Specified by:
- getInputStreamin interface- GFileSystem
- Parameters:
- file-- GFileto get an InputStream for
- monitor-- TaskMonitorto watch and update progress
- Returns:
- new InputStreamcontains the contents of the file or NULL if the file doesn't have data.
- Throws:
- CancelledException- if user cancels.
- java.io.IOException- if IO problem
 
 - 
debugprotected void debug(byte[] bytes, java.lang.String fileName)Writes the given bytes to a tempfile in the temp directory.- Parameters:
- bytes- the bytes to write
- fileName- the prefix of the temp file name
 
 - 
lookuppublic GFile lookup(java.lang.String path) throws java.io.IOException Description copied from interface:GFileSystemRetrieves aGFilefrom this filesystem based on its full path and filename.- Specified by:
- lookupin interface- GFileSystem
- Parameters:
- path- string path and filename of a file located in this filesystem. Use- nullor "/" to retrieve the root directory
- Returns:
- GFileinstance of requested file, null if not found.
- Throws:
- java.io.IOException- if IO error when looking up file.
 
 - 
getRefManagerpublic FileSystemRefManager getRefManager() Description copied from interface:GFileSystemReturns theref managerthat is responsible for creating and releasingrefsto this filesystem.- Specified by:
- getRefManagerin interface- GFileSystem
- Returns:
- FileSystemRefManagerthat manages references to this filesystem.
 
 
- 
 
-