Package org.jboss.vfs.spi
Interface FileSystem
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
AssemblyFileSystem
,JavaZipFileSystem
,RealFileSystem
,RootFileSystem
public interface FileSystem extends java.io.Closeable
A file system which is mounted in to the VFS. This is the driver class for a given virtual file system type. An instance ofFileSystem
will be mounted at some point on a VFS. The specific instance is only called when a file from this filesystem is called upon. The path components passed in to the operations are canonical, with no "." or ".." components.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Destroy this filesystem instance.boolean
delete(VirtualFile mountPoint, VirtualFile target)
Attempt to delete a virtual file within this filesystem.boolean
exists(VirtualFile mountPoint, VirtualFile target)
Ascertain the existance of a virtual file within this filesystem.java.security.CodeSigner[]
getCodeSigners(VirtualFile mountPoint, VirtualFile target)
Get theCodeSigner
s for a the virtual file.java.util.List<java.lang.String>
getDirectoryEntries(VirtualFile mountPoint, VirtualFile target)
Read a directory.java.io.File
getFile(VirtualFile mountPoint, VirtualFile target)
Get a realFile
for the given path within this filesystem.long
getLastModified(VirtualFile mountPoint, VirtualFile target)
Get the last modification time of a virtual file within this filesystem.java.io.File
getMountSource()
Get theFile
source provided at mount time.java.net.URI
getRootURI()
Get the root URI for this file system, ornull
if there is no valid root URI.long
getSize(VirtualFile mountPoint, VirtualFile target)
Get the size of a virtual file within this filesystem.boolean
isDirectory(VirtualFile mountPoint, VirtualFile target)
Ascertain whether a virtual file within this filesystem is a directory.boolean
isFile(VirtualFile mountPoint, VirtualFile target)
Ascertain whether a virtual file within this filesystem is a plain file.boolean
isReadOnly()
Determine whether this filesystem is read-only.java.io.InputStream
openInputStream(VirtualFile mountPoint, VirtualFile target)
Open an input stream for the file at the given relative path.
-
-
-
Method Detail
-
getFile
java.io.File getFile(VirtualFile mountPoint, VirtualFile target) throws java.io.IOException
Get a realFile
for the given path within this filesystem. Some filesystem types will need to make a copy in order to return this file; such copies should be cached and retained until the filesystem is closed. Depending on the file type, the real path of the returnedFile
may or may not bear a relationship to the virtual path provided; if such a relationship is required, it must be negotiated at the time the filesystem is mounted.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
- the file instance
- Throws:
java.io.IOException
- if an I/O error occurs
-
openInputStream
java.io.InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws java.io.IOException
Open an input stream for the file at the given relative path.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
- the input stream
- Throws:
java.io.IOException
- if an I/O error occurs
-
isReadOnly
boolean isReadOnly()
Determine whether this filesystem is read-only. A read-only filesystem prohibits file modification or deletion. It is not an error to mount a read-write filesystem within a read-only filesystem however (this operation does not take place within theFileSystem
implementation).- Returns:
true
if the filesystem is read-only
-
delete
boolean delete(VirtualFile mountPoint, VirtualFile target)
Attempt to delete a virtual file within this filesystem.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
true
if the file was deleted,false
if it failed for any reason
-
getSize
long getSize(VirtualFile mountPoint, VirtualFile target)
Get the size of a virtual file within this filesystem.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
- the size, in bytes, or 0L if the file does not exist or is a directory
-
getLastModified
long getLastModified(VirtualFile mountPoint, VirtualFile target)
Get the last modification time of a virtual file within this filesystem.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
- the modification time in milliseconds, or 0L if the file does not exist or if an error occurs
-
exists
boolean exists(VirtualFile mountPoint, VirtualFile target)
Ascertain the existance of a virtual file within this filesystem.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
true
if the file exists,false
otherwise- Throws:
java.io.IOException
- if an I/O error occurs
-
isFile
boolean isFile(VirtualFile mountPoint, VirtualFile target)
Ascertain whether a virtual file within this filesystem is a plain file.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
true
if the file exists and is a plain file,false
otherwise
-
isDirectory
boolean isDirectory(VirtualFile mountPoint, VirtualFile target)
Ascertain whether a virtual file within this filesystem is a directory.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
true
if the file exists and is a directory,false
otherwise
-
getDirectoryEntries
java.util.List<java.lang.String> getDirectoryEntries(VirtualFile mountPoint, VirtualFile target)
Read a directory. Returns all the simple path names (excluding "." and ".."). The returned list will be empty if the node is not a directory.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
- the collection of children names
-
getCodeSigners
java.security.CodeSigner[] getCodeSigners(VirtualFile mountPoint, VirtualFile target)
Get theCodeSigner
s for a the virtual file.- Parameters:
mountPoint
- the mount point of the filesystem instance (guaranteed to be a parent oftarget
)target
- the virtual file to act upon- Returns:
CodeSigner
for the virtual file or null if not signed.
-
close
void close() throws java.io.IOException
Destroy this filesystem instance. After this method is called, the filesystem may not be used in any way. This method should be called only after all mounts of this filesystem have been cleared; otherwise, VFS accesses may result inIOException
s.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
- if an I/O error occurs during close
-
getMountSource
java.io.File getMountSource()
Get theFile
source provided at mount time.- Returns:
- the source used for mounting
-
getRootURI
java.net.URI getRootURI() throws java.net.URISyntaxException
Get the root URI for this file system, ornull
if there is no valid root URI.- Returns:
- the root URI
- Throws:
java.net.URISyntaxException
- if the URI isn't valid
-
-