Interface GFileSystem
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
,ExtensionPoint
- All Known Implementing Classes:
GFileSystemBase
,LocalFileSystem
,LocalFileSystemSub
public interface GFileSystem extends java.io.Closeable, ExtensionPoint
Interface that represents a filesystem that contains files.Operations take a
TaskMonitor
if they need to be cancel-able.Use a
FileSystemService instance
to discover and open instances of filesystems in files or to open a knownFSRL
path or to deal with creatingtemp files
.NOTE:
ALL GFileSystem sub-CLASSES MUST END IN "FileSystem". If not, the ClassSearcher will not find them.
Also note that this interface came after the original abstract class GFileSystem and its many implementations, and usage is being migrated to this interface where possible and as time permits.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description ByteProvider
getByteProvider(GFile file, TaskMonitor monitor)
Returns aByteProvider
that contains the contents of the specifiedGFile
.default java.lang.String
getDescription()
Returns a description of this file system.default FileAttributes
getFileAttributes(GFile file, TaskMonitor monitor)
Returns a container ofFileAttribute
values.default int
getFileCount()
Returns the number of files in the filesystem, if known, otherwise -1 if not known.FSRLRoot
getFSRL()
File system's FSRLdefault java.io.InputStream
getInputStream(GFile file, TaskMonitor monitor)
Returns anInputStream
that contains the contents of the specifiedGFile
.static java.io.InputStream
getInputStreamHelper(GFile file, GFileSystem fs, TaskMonitor monitor)
java.util.List<GFile>
getListing(GFile directory)
Returns a list offiles
that reside in the specified directory on this filesystem.java.lang.String
getName()
File system volume name.FileSystemRefManager
getRefManager()
Returns theref manager
that is responsible for creating and releasingrefs
to this filesystem.default java.lang.String
getType()
Returns the type of this file system.boolean
isClosed()
Returns true if the filesystem has beenclosed
default boolean
isStatic()
Indicates if this filesystem is a static snapshot or changes.GFile
lookup(java.lang.String path)
Retrieves aGFile
from this filesystem based on its full path and filename.
-
-
-
Method Detail
-
getName
java.lang.String getName()
File system volume name.Typically the name of the container file, or a internally stored 'volume' name.
- Returns:
- string filesystem volume name.
-
getType
default java.lang.String getType()
Returns the type of this file system.This default implementation returns the type value in
FileSystemInfo
annotation.- Returns:
- type string
-
getDescription
default java.lang.String getDescription()
Returns a description of this file system.This default implementation returns the description value in
FileSystemInfo
annotation.- Returns:
- description string
-
isClosed
boolean isClosed()
Returns true if the filesystem has beenclosed
- Returns:
- boolean true if the filesystem has been closed.
-
isStatic
default boolean isStatic()
Indicates if this filesystem is a static snapshot or changes.- Returns:
- boolean true if the filesystem is static or false if dynamic content.
-
getRefManager
FileSystemRefManager getRefManager()
Returns theref manager
that is responsible for creating and releasingrefs
to this filesystem.- Returns:
FileSystemRefManager
that manages references to this filesystem.
-
getFileCount
default int getFileCount()
Returns the number of files in the filesystem, if known, otherwise -1 if not known.- Returns:
- number of files in this filesystem, -1 if not known.
-
lookup
GFile lookup(java.lang.String path) throws java.io.IOException
Retrieves aGFile
from this filesystem based on its full path and filename.- Parameters:
path
- string path and filename of a file located in this filesystem. Usenull
or "/" to retrieve the root directory- Returns:
GFile
instance of requested file, null if not found.- Throws:
java.io.IOException
- if IO error when looking up file.
-
getInputStream
default java.io.InputStream getInputStream(GFile file, TaskMonitor monitor) throws java.io.IOException, CancelledException
Returns anInputStream
that contains the contents of the specifiedGFile
.The caller is responsible for closing the stream.
- Parameters:
file
-GFile
to get an InputStream formonitor
-TaskMonitor
to watch and update progress- Returns:
- new
InputStream
contains the contents of the file or NULL if the file doesn't have data. - Throws:
java.io.IOException
- if IO problemCancelledException
- if user cancels.
-
getByteProvider
ByteProvider getByteProvider(GFile file, TaskMonitor monitor) throws java.io.IOException, CancelledException
Returns aByteProvider
that contains the contents of the specifiedGFile
.The caller is responsible for closing the provider.
- Parameters:
file
-GFile
to get bytes formonitor
-TaskMonitor
to watch and update progress- Returns:
- new
ByteProvider
that contains the contents of the file, or NULL if file doesn't have data - Throws:
java.io.IOException
- if errorCancelledException
- if user cancels
-
getListing
java.util.List<GFile> getListing(GFile directory) throws java.io.IOException
Returns a list offiles
that reside in the specified directory on this filesystem.- Parameters:
directory
- NULL means root of filesystem.- Returns:
List
ofGFile
instances of file in the requested directory.- Throws:
java.io.IOException
- if IO problem.
-
getFileAttributes
default FileAttributes getFileAttributes(GFile file, TaskMonitor monitor)
Returns a container ofFileAttribute
values.Implementors of this method are not required to add FSRL, NAME, or PATH values unless the values are non-standard.
- Parameters:
file
-GFile
to get the attributes formonitor
-TaskMonitor
- Returns:
FileAttributes
instance (possibly read-only), maybe empty but never null
-
getInputStreamHelper
static java.io.InputStream getInputStreamHelper(GFile file, GFileSystem fs, TaskMonitor monitor) throws CancelledException, java.io.IOException
- Parameters:
file
-GFile
fs
- thefilesystem
containing the filemonitor
-TaskMonitor
to allow canceling- Returns:
- new
InputStream
containing bytes of the file - Throws:
CancelledException
- if canceledjava.io.IOException
- if error
-
-