public class CachingFs extends FullFileSystem
| Constructor and Description |
|---|
CachingFs(FileSystem innerFs)
Creates a new instance of the caching file system
|
CachingFs(FileSystem innerFs,
int cacheSize)
Creates a new instance of the caching file system
|
| Modifier and Type | Method and Description |
|---|---|
void |
afterUnmounting()
Is called after the file system has been unmounted successfully.
|
void |
beforeMounting(java.lang.String mountPath)
Is called directly before the file system is mounted
|
void |
beforeUnmounting()
Is called directly before the file system is unmounted
|
void |
close(FileHandle fh)
Closes the file handle.
|
void |
createDirectory(java.lang.String path)
Creates a new, empty directory.
|
void |
createFile(java.lang.String path)
Creates a new (blank) file.
|
void |
createHardLink(java.lang.String source,
java.lang.String destination)
Creates a hard link at source pointing to destination.
|
void |
createSymbolicLink(java.lang.String from,
java.lang.String to)
Creates a symbolic link at source pointing to destination.
|
void |
deleteDirectoryRecursively(java.lang.String directory)
Deletes a directory recursively.
|
void |
deleteFile(java.lang.String file)
Deletes a file or symbolic link.
|
void |
flush(FileHandle fh)
Should write all pending data in the cache.
|
int |
getBlockSize()
Returns the block size in bytes
|
EntityInfo |
getFileMetaData(java.lang.String path)
Returns some meta data about the path.
|
int |
getFilesFreeCount()
Returns the number of files which may be created.
|
java.lang.String |
getFileSystemName()
Returns the file system name
|
long |
getFreeBlockAvailableCount()
Returns the number of free blocks, which are available to the current user.
|
long |
getFreeBlockCount()
Returns the number of free blocks.
|
int |
getMaxPathLength()
Returns the maximum path length.
|
long |
getTotalBlockCount()
Returns the number of total blocks.
|
int |
getTotalFilesCount()
Returns the total number of files on the volume.
|
UnixPermissions |
getUnixPermissions(java.lang.String path)
Returns the unix permissions
|
java.lang.String |
getVolumeName()
Returns the volume name.
|
int |
getVolumeSerialNumber()
Returns a volume serial number
|
WindowsAttributes |
getWindowsAttributes(java.lang.String path)
Returns the windows attributes.
|
boolean |
isCaseSensitive()
Returns true if the pathes are case sensitive
|
boolean |
isCompressed()
Returns true if the file system is compressed
|
boolean |
isReadOnly()
Returns true if the file system is read only
|
java.lang.Iterable<EntityInfo> |
listDirectory(java.lang.String path)
Reads a given directory and returns an iterator.
|
java.lang.Iterable<ExtendedAttribute> |
listExtendedAttributes(java.lang.String path)
Lists the extended attributes of a path.
|
void |
lockFile(FileHandle handle,
long byteOffset,
long length)
Locks a file in the specified range for every write access except for the File Handle handle.
|
FileHandle |
openFile(java.lang.String path,
boolean read,
boolean write)
Opens a file.
|
int |
read(FileHandle fh,
java.nio.ByteBuffer buffer,
long offset)
Reads from a file.
|
void |
removeExtendedAttribute(java.lang.String path,
java.lang.String attributeName)
Sets or adds extended attributes.
|
void |
rename(java.lang.String from,
java.lang.String to)
Renames a file/directory/symbolic link.
|
void |
setCreationTime(java.lang.String path,
long creationTime)
Sets the creation time (unix timestamp).
|
void |
setExtendedAttribute(java.lang.String path,
ExtendedAttribute attribute)
Sets or adds extended attribute.
|
void |
setLastAccessTime(java.lang.String path,
long atime)
Sets the last access time (unix timestamp).
|
void |
setLastModificationTime(java.lang.String path,
long mtime)
Sets the last modification time (unix timestamp).
|
void |
setLength(FileHandle fh,
long length)
Truncates or lengthens a file.
|
void |
setUnixPermissions(java.lang.String path,
UnixPermissions perms)
Sets the unix permissions for a file/directory.
|
void |
setWindowsAttributes(java.lang.String path,
WindowsAttributes windowsAttributes)
Sets the windows attributes.
|
boolean |
supportsUnicodeFilenames()
Returns true if the file system supports unicode filenames.
|
void |
unlockFile(FileHandle handle,
long byteOffset,
long length)
Unlocks a file in the specified range.
|
void |
write(FileHandle fh,
java.nio.ByteBuffer buffer,
long offset)
(Over-)writes the buffer into the specified file handle.
|
delete, getExtendedAttribute, getMountPath, getNumberOfFilesInDirectory, pathExistspublic CachingFs(FileSystem innerFs)
innerFs - the inner file systempublic CachingFs(FileSystem innerFs, int cacheSize)
innerFs - the inner file systemcacheSize - the cache size per entry in bytespublic void deleteFile(java.lang.String file)
throws PathNotFoundException,
AccessDeniedException
FileSystemdeleteFile in class FileSystemfile - the filePathNotFoundException - the file could not be foundAccessDeniedException - the access is deniedpublic void createSymbolicLink(java.lang.String from,
java.lang.String to)
throws PathNotFoundException,
SourceAlreadyExistsException,
AccessDeniedException,
UnsupportedFeatureException
FileSystemcreateSymbolicLink in class FullFileSystemfrom - the sourceto - the destinationPathNotFoundException - the parent directory (of source) could not be foundSourceAlreadyExistsException - the source does already existAccessDeniedException - the access was deniedUnsupportedFeatureException - the feature is unsupportedhttps://en.wikipedia.org/wiki/Symbolic_linkpublic FileHandle openFile(java.lang.String path, boolean read, boolean write) throws PathNotFoundException, AccessDeniedException, NotAFileException
FileSystemopenFile in class FileSystempath - the file to openread - whether the file should be open to readwrite - whether the file should be open to writePathNotFoundException - the file was not foundAccessDeniedException - the access is deniedNotAFileException - the given path is not a filepublic void createFile(java.lang.String path)
throws PathNotFoundException,
DestinationAlreadyExistsException,
AccessDeniedException
FileSystemcreateFile in class FileSystempath - the path to the filePathNotFoundException - the parent directory could not be foundDestinationAlreadyExistsException - the destination already exists (regardless whether it is a directory or a file)AccessDeniedException - the access is deniedpublic void createDirectory(java.lang.String path)
throws PathNotFoundException,
DestinationAlreadyExistsException,
AccessDeniedException
FileSystemcreateDirectory in class FileSystempath - the path to the new directoryPathNotFoundException - the parent directory could not be foundDestinationAlreadyExistsException - the destination already exists (regardless whether it is a directory or a file)AccessDeniedException - the access is deniedpublic int read(FileHandle fh, java.nio.ByteBuffer buffer, long offset)
FileSystemread in class FileSystemfh - the file handlebuffer - the buffer to filloffset - the offset within the filepublic void write(FileHandle fh, java.nio.ByteBuffer buffer, long offset) throws DriveFullException, PartIsLockedException
FileSystem
Be careful: offset may be larger than the file size!
In this case you should fill everything in between with zeros.
write in class FileSystemfh - the file handle.buffer - the buffer to writeoffset - the offset within the fileDriveFullException - there is no more spacePartIsLockedException - the specified range has been lockedpublic void flush(FileHandle fh) throws DriveFullException
FileSystemflush in class FileSystemfh - the file handleDriveFullException - there is no more free spacepublic void close(FileHandle fh) throws DriveFullException
FileSystemclose in class FileSystemfh - the file handleDriveFullException - there is no more spacepublic void deleteDirectoryRecursively(java.lang.String directory)
throws PathNotFoundException,
AccessDeniedException
FileSystemdeleteDirectoryRecursively in class FileSystemdirectory - the directoryPathNotFoundException - the directory could not be foundAccessDeniedException - the access is deniedpublic java.lang.Iterable<EntityInfo> listDirectory(java.lang.String path) throws NotADirectoryException, PathNotFoundException, AccessDeniedException
FileSystemlistDirectory in class FileSystempath - the pathNotADirectoryException - the path is not a directoryPathNotFoundException - the path could not be foundAccessDeniedException - the access is deniedpublic EntityInfo getFileMetaData(java.lang.String path) throws PathNotFoundException
FileSystemgetFileMetaData in class FileSystempath - the pathPathNotFoundException - the path could not be foundpublic void rename(java.lang.String from,
java.lang.String to)
throws PathNotFoundException,
DestinationAlreadyExistsException,
AccessDeniedException
FileSystemrename in class FileSystemfrom - the source pathto - the destination pathPathNotFoundException - the source path or the parent directory of the destination could not be foundDestinationAlreadyExistsException - the destination already existsAccessDeniedException - the access is deniedpublic java.lang.String getVolumeName()
FileSystemgetVolumeName in class FileSystempublic java.lang.String getFileSystemName()
FileSystemgetFileSystemName in class FileSystempublic void setLength(FileHandle fh, long length) throws DriveFullException
FileSystemsetLength in class FileSystemfh - the file handlelength - the new file size in bytesDriveFullException - there is no more spacepublic void setLastAccessTime(java.lang.String path,
long atime)
throws PathNotFoundException,
AccessDeniedException
FileSystemsetLastAccessTime in class FileSystempath - the pathatime - the last access time (unix timestamp)PathNotFoundException - the path could not be found.AccessDeniedException - the access is deniedpublic void setLastModificationTime(java.lang.String path,
long mtime)
throws PathNotFoundException,
AccessDeniedException
FileSystemsetLastModificationTime in class FileSystempath - the pathmtime - the last modification time (unix timestamp)PathNotFoundException - the path could not be found.AccessDeniedException - the access is deniedpublic void setCreationTime(java.lang.String path,
long creationTime)
throws PathNotFoundException,
AccessDeniedException
FileSystemsetCreationTime in class FileSystempath - the pathcreationTime - the creation time (unix timestamp)PathNotFoundException - the path could not be found.AccessDeniedException - the access is deniedpublic boolean isCaseSensitive()
FileSystemisCaseSensitive in class FileSystempublic int getBlockSize()
FileSystemgetBlockSize in class FileSystempublic long getTotalBlockCount()
FileSystemgetTotalBlockCount in class FileSystempublic long getFreeBlockCount()
FileSystemgetFreeBlockCount in class FileSystempublic int getFilesFreeCount()
FileSystemgetFilesFreeCount in class FullFileSystempublic int getTotalFilesCount()
FileSystemgetTotalFilesCount in class FullFileSystempublic long getFreeBlockAvailableCount()
FileSystemgetFreeBlockAvailableCount in class FileSystempublic boolean supportsUnicodeFilenames()
FileSystemsupportsUnicodeFilenames in class FullFileSystempublic boolean isCompressed()
FileSystemisCompressed in class FullFileSystempublic int getVolumeSerialNumber()
FileSystemgetVolumeSerialNumber in class FullFileSystempublic boolean isReadOnly()
FileSystemisReadOnly in class FullFileSystempublic void createHardLink(java.lang.String source,
java.lang.String destination)
throws PathNotFoundException,
SourceAlreadyExistsException,
AccessDeniedException,
UnsupportedFeatureException
FileSystemcreateHardLink in class FullFileSystemsource - the sourcedestination - the destinationPathNotFoundException - the parent directory could not be foundSourceAlreadyExistsException - the source does already existAccessDeniedException - the access was deniedUnsupportedFeatureException - the feature is unsupportedhttps://en.wikipedia.org/wiki/Hard_linkpublic int getMaxPathLength()
FileSystemgetMaxPathLength in class FullFileSystempublic void setUnixPermissions(java.lang.String path,
UnixPermissions perms)
throws PathNotFoundException,
AccessDeniedException,
UnsupportedFeatureException
FileSystemsetUnixPermissions in class FullFileSystempath - the pathperms - the permissionsPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is unsupportedpublic UnixPermissions getUnixPermissions(java.lang.String path) throws PathNotFoundException
FileSystemgetUnixPermissions in class FullFileSystempath - the pathPathNotFoundException - the path was not foundpublic void setWindowsAttributes(java.lang.String path,
WindowsAttributes windowsAttributes)
throws PathNotFoundException,
AccessDeniedException,
UnsupportedFeatureException
FileSystemsetWindowsAttributes in class FullFileSystempath - the pathwindowsAttributes - the windows attributesPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is not supportedpublic WindowsAttributes getWindowsAttributes(java.lang.String path) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
FileSystemgetWindowsAttributes in class FullFileSystempath - the pathPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is not supportedpublic void lockFile(FileHandle handle, long byteOffset, long length) throws PathNotFoundException, AccessDeniedException, NotAFileException, UnsupportedFeatureException, AlreadyLockedException
FileSystemlockFile in class FullFileSystemhandle - the file handlebyteOffset - the byte offsetlength - the lengthPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedNotAFileException - the path is not a fileUnsupportedFeatureException - the feature is not supportedAlreadyLockedException - parts of the specified range are already lockedpublic void unlockFile(FileHandle handle, long byteOffset, long length) throws PathNotFoundException, AccessDeniedException, NotAFileException, UnsupportedFeatureException
FileSystemunlockFile in class FullFileSystemhandle - the file handlebyteOffset - the byte offsetlength - the lengthPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedNotAFileException - the path is not a fileUnsupportedFeatureException - the feature is not supportedpublic java.lang.Iterable<ExtendedAttribute> listExtendedAttributes(java.lang.String path) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
FileSystemlistExtendedAttributes in class FullFileSystempath - the pathPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is not supportedpublic void setExtendedAttribute(java.lang.String path,
ExtendedAttribute attribute)
throws PathNotFoundException,
AccessDeniedException,
UnsupportedFeatureException
FileSystemsetExtendedAttribute in class FullFileSystempath - the pathattribute - the attribute to add/setPathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is not supportedpublic void removeExtendedAttribute(java.lang.String path,
java.lang.String attributeName)
throws PathNotFoundException,
AccessDeniedException,
UnsupportedFeatureException,
AttributeNotFoundException
FileSystemremoveExtendedAttribute in class FullFileSystempath - the pathattributeName - the attribute namePathNotFoundException - the path was not foundAccessDeniedException - the access is deniedUnsupportedFeatureException - the feature is not supportedAttributeNotFoundException - the specified attribute was not foundpublic void beforeMounting(java.lang.String mountPath)
FileSystembeforeMounting in class FullFileSystemmountPath - the mount pathpublic void beforeUnmounting()
FileSystembeforeUnmounting in class FullFileSystempublic void afterUnmounting()
FileSystemafterUnmounting in class FullFileSystem