Interface GFileSystem
- All Superinterfaces:
AutoCloseable,Closeable,ExtensionPoint,Iterable<GFile>
- All Known Implementing Classes:
AbstractFileSystem,GFileSystemBase,LocalFileSystem,LocalFileSystemSub
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 known FSRL path or to
deal with creating temp 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
Modifier and TypeMethodDescriptionfiles()getByteProvider(GFile file, TaskMonitor monitor) Returns aByteProviderthat contains the contents of the specifiedGFile.default StringReturns a description of this file system.default FileAttributesgetFileAttributes(GFile file, TaskMonitor monitor) Returns a container ofFileAttributevalues.default intReturns the number of files in the filesystem, if known, otherwise -1 if not known.getFSRL()File system's FSRLdefault InputStreamgetInputStream(GFile file, TaskMonitor monitor) Returns anInputStreamthat contains the contents of the specifiedGFile.static InputStreamgetInputStreamHelper(GFile file, GFileSystem fs, TaskMonitor monitor) getListing(GFile directory) Returns a list offilesthat reside in the specified directory on this filesystem.getName()File system volume name.Returns theref managerthat is responsible for creating and releasingrefsto this filesystem.default GFileReturns the file system's root directory.default StringgetType()Returns the type of this file system.booleanisClosed()Returns true if the filesystem has beencloseddefault booleanisStatic()Indicates if this filesystem is a static snapshot or changes.iterator()Retrieves aGFilefrom this filesystem based on its full path and filename, using this filesystem's default name comparison logic (eg.default GFilelookup(String path, Comparator<String> nameComp) Retrieves aGFilefrom this filesystem based on its full path and filename, using the specified name comparison logic (eg.default GFileresolveSymlinks(GFile file) Converts the specified (symlink) file into it's destination, or if not a symlink, returns the original file unchanged.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getName
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
Returns the type of this file system.This default implementation returns the type value in
FileSystemInfoannotation.- Returns:
- type string
-
getDescription
Returns a description of this file system.This default implementation returns the description value in
FileSystemInfoannotation.- Returns:
- description string
-
getFSRL
FSRLRoot getFSRL()File system's FSRL- Returns:
FSRLRootof this filesystem.
-
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 managerthat is responsible for creating and releasingrefsto this filesystem.- Returns:
FileSystemRefManagerthat 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
Retrieves aGFilefrom this filesystem based on its full path and filename, using this filesystem's default name comparison logic (eg. case sensitive vs insensitive).- 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
Retrieves aGFilefrom this filesystem based on its full path and filename, using the specified name comparison logic (eg. case sensitive vs insensitive).- 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.
-
getRootDir
Returns the file system's root directory.Note: using
nullwhen callinggetListing(GFile)is also valid.- Returns:
- file system's root directory
-
getInputStream
default InputStream getInputStream(GFile file, TaskMonitor monitor) throws IOException, CancelledException Returns anInputStreamthat contains the contents of the specifiedGFile.The caller is responsible for closing the stream.
- Parameters:
file-GFileto get an InputStream formonitor-TaskMonitorto watch and update progress- Returns:
- new
InputStreamcontains the contents of the file or NULL if the file doesn't have data. - Throws:
IOException- if IO problemCancelledException- if user cancels.
-
getByteProvider
ByteProvider getByteProvider(GFile file, TaskMonitor monitor) throws IOException, CancelledException Returns aByteProviderthat contains the contents of the specifiedGFile.The caller is responsible for closing the provider.
- Parameters:
file-GFileto get bytes formonitor-TaskMonitorto watch and update progress- Returns:
- new
ByteProviderthat contains the contents of the file, or NULL if file doesn't have data - Throws:
IOException- if errorCancelledException- if user cancels
-
getListing
Returns a list offilesthat reside in the specified directory on this filesystem.- Parameters:
directory- NULL means root of filesystem.- Returns:
ListofGFileinstances of file in the requested directory.- Throws:
IOException- if IO problem.
-
getFileAttributes
Returns a container ofFileAttributevalues.Implementors of this method are not required to add FSRL, NAME, or PATH values unless the values are non-standard.
- Parameters:
file-GFileto get the attributes formonitor-TaskMonitor- Returns:
FileAttributesinstance (possibly read-only), maybe empty but never null
-
resolveSymlinks
Converts the specified (symlink) file into it's destination, or if not a symlink, returns the original file unchanged.- Parameters:
file- symlink file to follow- Returns:
- destination of symlink, or original file if not a symlink
- Throws:
IOException- if error following symlink path, typically outside of the hosting file system
-
getInputStreamHelper
static InputStream getInputStreamHelper(GFile file, GFileSystem fs, TaskMonitor monitor) throws CancelledException, IOException - Parameters:
file-GFilefs- thefilesystemcontaining the filemonitor-TaskMonitorto allow canceling- Returns:
- new
InputStreamcontaining bytes of the file - Throws:
CancelledException- if canceledIOException- if error
-
files
- Returns:
- An
Iterableover thisGFileSystem'sfiles.
-
files
- Parameters:
dir- Thedirectoryto start iterating at in thisGFileSystem. Ifnull, iteration will start at the root of theGFileSystem.- Returns:
- An
Iterableover thisGFileSystem'sfiles. - Throws:
UncheckedIOException- ifdiris not a directory
-
files
- Parameters:
fileFilter- A filter to apply to thefilesiterated over- Returns:
- An
Iterableover thisGFileSystem'sfiles.
-
files
- Parameters:
dir- Thedirectoryto start iterating at in thisGFileSystem. Ifnull, iteration will start at the root of theGFileSystem.fileFilter- A filter to apply to thefilesiterated over- Returns:
- An
Iterableover thisGFileSystem'sfiles. - Throws:
UncheckedIOException- ifdiris not a directory
-
iterator
-