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, pathExists
public 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
FileSystem
deleteFile
in class FileSystem
file
- 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
FileSystem
createSymbolicLink
in class FullFileSystem
from
- 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_link
public FileHandle openFile(java.lang.String path, boolean read, boolean write) throws PathNotFoundException, AccessDeniedException, NotAFileException
FileSystem
openFile
in class FileSystem
path
- 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
FileSystem
createFile
in class FileSystem
path
- 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
FileSystem
createDirectory
in class FileSystem
path
- 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)
FileSystem
read
in class FileSystem
fh
- 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 FileSystem
fh
- 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
FileSystem
flush
in class FileSystem
fh
- the file handleDriveFullException
- there is no more free spacepublic void close(FileHandle fh) throws DriveFullException
FileSystem
close
in class FileSystem
fh
- the file handleDriveFullException
- there is no more spacepublic void deleteDirectoryRecursively(java.lang.String directory) throws PathNotFoundException, AccessDeniedException
FileSystem
deleteDirectoryRecursively
in class FileSystem
directory
- 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
FileSystem
listDirectory
in class FileSystem
path
- 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
FileSystem
getFileMetaData
in class FileSystem
path
- the pathPathNotFoundException
- the path could not be foundpublic void rename(java.lang.String from, java.lang.String to) throws PathNotFoundException, DestinationAlreadyExistsException, AccessDeniedException
FileSystem
rename
in class FileSystem
from
- 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()
FileSystem
getVolumeName
in class FileSystem
public java.lang.String getFileSystemName()
FileSystem
getFileSystemName
in class FileSystem
public void setLength(FileHandle fh, long length) throws DriveFullException
FileSystem
setLength
in class FileSystem
fh
- 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
FileSystem
setLastAccessTime
in class FileSystem
path
- 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
FileSystem
setLastModificationTime
in class FileSystem
path
- 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
FileSystem
setCreationTime
in class FileSystem
path
- the pathcreationTime
- the creation time (unix timestamp)PathNotFoundException
- the path could not be found.AccessDeniedException
- the access is deniedpublic boolean isCaseSensitive()
FileSystem
isCaseSensitive
in class FileSystem
public int getBlockSize()
FileSystem
getBlockSize
in class FileSystem
public long getTotalBlockCount()
FileSystem
getTotalBlockCount
in class FileSystem
public long getFreeBlockCount()
FileSystem
getFreeBlockCount
in class FileSystem
public int getFilesFreeCount()
FileSystem
getFilesFreeCount
in class FullFileSystem
public int getTotalFilesCount()
FileSystem
getTotalFilesCount
in class FullFileSystem
public long getFreeBlockAvailableCount()
FileSystem
getFreeBlockAvailableCount
in class FileSystem
public boolean supportsUnicodeFilenames()
FileSystem
supportsUnicodeFilenames
in class FullFileSystem
public boolean isCompressed()
FileSystem
isCompressed
in class FullFileSystem
public int getVolumeSerialNumber()
FileSystem
getVolumeSerialNumber
in class FullFileSystem
public boolean isReadOnly()
FileSystem
isReadOnly
in class FullFileSystem
public void createHardLink(java.lang.String source, java.lang.String destination) throws PathNotFoundException, SourceAlreadyExistsException, AccessDeniedException, UnsupportedFeatureException
FileSystem
createHardLink
in class FullFileSystem
source
- 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_link
public int getMaxPathLength()
FileSystem
getMaxPathLength
in class FullFileSystem
public void setUnixPermissions(java.lang.String path, UnixPermissions perms) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
FileSystem
setUnixPermissions
in class FullFileSystem
path
- 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
FileSystem
getUnixPermissions
in class FullFileSystem
path
- the pathPathNotFoundException
- the path was not foundpublic void setWindowsAttributes(java.lang.String path, WindowsAttributes windowsAttributes) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
FileSystem
setWindowsAttributes
in class FullFileSystem
path
- 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
FileSystem
getWindowsAttributes
in class FullFileSystem
path
- 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
FileSystem
lockFile
in class FullFileSystem
handle
- 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
FileSystem
unlockFile
in class FullFileSystem
handle
- 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
FileSystem
listExtendedAttributes
in class FullFileSystem
path
- 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
FileSystem
setExtendedAttribute
in class FullFileSystem
path
- 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
FileSystem
removeExtendedAttribute
in class FullFileSystem
path
- 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)
FileSystem
beforeMounting
in class FullFileSystem
mountPath
- the mount pathpublic void beforeUnmounting()
FileSystem
beforeUnmounting
in class FullFileSystem
public void afterUnmounting()
FileSystem
afterUnmounting
in class FullFileSystem