public abstract class FileSystem
extends java.lang.Object
Constructor and Description |
---|
FileSystem() |
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
|
abstract void |
close(FileHandle handle)
Closes the file handle.
|
abstract void |
createDirectory(java.lang.String path)
Creates a new, empty directory.
|
abstract 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 source,
java.lang.String destination)
Creates a symbolic link at source pointing to destination.
|
void |
delete(java.lang.String path)
Checks whether path is a file or directory and calls the appropriate method
|
abstract void |
deleteDirectoryRecursively(java.lang.String directory)
Deletes a directory recursively.
|
abstract void |
deleteFile(java.lang.String file)
Deletes a file or symbolic link.
|
abstract void |
flush(FileHandle handle)
Should write all pending data in the cache.
|
abstract int |
getBlockSize()
Returns the block size in bytes
|
ExtendedAttribute |
getExtendedAttribute(java.lang.String path,
java.lang.String name)
Returns one specific extended attribute.
|
abstract EntityInfo |
getFileMetaData(java.lang.String path)
Returns some meta data about the path.
|
int |
getFilesFreeCount()
Returns the number of files which may be created.
|
abstract java.lang.String |
getFileSystemName()
Returns the file system name
|
abstract long |
getFreeBlockAvailableCount()
Returns the number of free blocks, which are available to the current user.
|
abstract long |
getFreeBlockCount()
Returns the number of free blocks.
|
int |
getMaxPathLength()
Returns the maximum path length.
|
java.lang.String |
getMountPath()
Returns the mount path
|
int |
getNumberOfFilesInDirectory(DirectoryInfo info)
Returns the number of files (and direct subdirectories) in a directory
|
abstract 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
|
abstract 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.
|
abstract 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
|
abstract 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.
|
abstract FileHandle |
openFile(java.lang.String file,
boolean read,
boolean write)
Opens a file.
|
boolean |
pathExists(java.lang.String path)
Checks whether the path already exists.
|
abstract int |
read(FileHandle handle,
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.
|
abstract void |
rename(java.lang.String source,
java.lang.String destination)
Renames a file/directory/symbolic link.
|
abstract void |
setCreationTime(java.lang.String path,
long ctime)
Sets the creation time (unix timestamp).
|
void |
setExtendedAttribute(java.lang.String path,
ExtendedAttribute attribute)
Sets or adds extended attribute.
|
abstract void |
setLastAccessTime(java.lang.String path,
long atime)
Sets the last access time (unix timestamp).
|
abstract void |
setLastModificationTime(java.lang.String path,
long mtime)
Sets the last modification time (unix timestamp).
|
abstract void |
setLength(FileHandle handle,
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.
|
abstract void |
write(FileHandle handle,
java.nio.ByteBuffer buffer,
long offset)
(Over-)writes the buffer into the specified file handle.
|
public abstract java.lang.Iterable<EntityInfo> listDirectory(java.lang.String path) throws NotADirectoryException, PathNotFoundException, AccessDeniedException
path
- the pathNotADirectoryException
- the path is not a directoryPathNotFoundException
- the path could not be foundAccessDeniedException
- the access is deniedpublic abstract EntityInfo getFileMetaData(java.lang.String path) throws PathNotFoundException
path
- the pathPathNotFoundException
- the path could not be foundpublic abstract void rename(java.lang.String source, java.lang.String destination) throws PathNotFoundException, DestinationAlreadyExistsException, AccessDeniedException
source
- the source pathdestination
- 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 abstract FileHandle openFile(java.lang.String file, boolean read, boolean write) throws PathNotFoundException, AccessDeniedException, NotAFileException
file
- 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 abstract void createFile(java.lang.String path) throws PathNotFoundException, DestinationAlreadyExistsException, AccessDeniedException
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 abstract void createDirectory(java.lang.String path) throws PathNotFoundException, DestinationAlreadyExistsException, AccessDeniedException
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 abstract int read(FileHandle handle, java.nio.ByteBuffer buffer, long offset)
handle
- the file handlebuffer
- the buffer to filloffset
- the offset within the filepublic abstract void setLength(FileHandle handle, long length) throws DriveFullException
handle
- the file handlelength
- the new file size in bytesDriveFullException
- there is no more spacepublic abstract void write(FileHandle handle, java.nio.ByteBuffer buffer, long offset) throws DriveFullException, PartIsLockedException
Be careful: offset may be larger than the file size!
In this case you should fill everything in between with zeros.
handle
- the file handle.buffer
- the buffer to writeoffset
- the offset within the fileDriveFullException
- there is no more spacePartIsLockedException
- the specified range has been lockedpublic abstract void flush(FileHandle handle) throws DriveFullException
handle
- the file handleDriveFullException
- there is no more free spacepublic abstract void close(FileHandle handle) throws DriveFullException
handle
- the file handleDriveFullException
- there is no more spacepublic abstract void deleteFile(java.lang.String file) throws PathNotFoundException, AccessDeniedException
file
- the filePathNotFoundException
- the file could not be foundAccessDeniedException
- the access is deniedNotAFileException
- the specified path is not a filepublic abstract void deleteDirectoryRecursively(java.lang.String directory) throws PathNotFoundException, AccessDeniedException
directory
- the directoryPathNotFoundException
- the directory could not be foundAccessDeniedException
- the access is deniedpublic abstract java.lang.String getVolumeName()
public abstract java.lang.String getFileSystemName()
public abstract void setLastAccessTime(java.lang.String path, long atime) throws PathNotFoundException, AccessDeniedException
path
- the pathatime
- the last access time (unix timestamp)PathNotFoundException
- the path could not be found.AccessDeniedException
- the access is deniedpublic abstract void setLastModificationTime(java.lang.String path, long mtime) throws PathNotFoundException, AccessDeniedException
path
- the pathmtime
- the last modification time (unix timestamp)PathNotFoundException
- the path could not be found.AccessDeniedException
- the access is deniedpublic abstract void setCreationTime(java.lang.String path, long ctime) throws PathNotFoundException, AccessDeniedException
path
- the pathctime
- the creation time (unix timestamp)PathNotFoundException
- the path could not be found.AccessDeniedException
- the access is deniedpublic abstract boolean isCaseSensitive()
public abstract int getBlockSize()
public abstract long getTotalBlockCount()
public abstract long getFreeBlockAvailableCount()
public abstract long getFreeBlockCount()
public java.lang.String getMountPath()
public void createSymbolicLink(java.lang.String source, java.lang.String destination) throws PathNotFoundException, SourceAlreadyExistsException, AccessDeniedException, UnsupportedFeatureException
source
- the sourcedestination
- 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 void createHardLink(java.lang.String source, java.lang.String destination) throws PathNotFoundException, SourceAlreadyExistsException, AccessDeniedException, UnsupportedFeatureException
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 boolean pathExists(java.lang.String path)
path
- the pathpublic int getMaxPathLength()
public int getFilesFreeCount()
public int getTotalFilesCount()
public void setUnixPermissions(java.lang.String path, UnixPermissions perms) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
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
path
- the pathPathNotFoundException
- the path was not foundpublic void setWindowsAttributes(java.lang.String path, WindowsAttributes windowsAttributes) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
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
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
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
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 int getNumberOfFilesInDirectory(DirectoryInfo info)
info
- the directory infopublic final void delete(java.lang.String path) throws PathNotFoundException, AccessDeniedException
path
- the pathPathNotFoundException
- the path was not foundAccessDeniedException
- the access is deniedpublic boolean supportsUnicodeFilenames()
public boolean isCompressed()
public int getVolumeSerialNumber()
public boolean isReadOnly()
public ExtendedAttribute getExtendedAttribute(java.lang.String path, java.lang.String name) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException, AttributeNotFoundException
path
- the path of the filename
- the name of the attributePathNotFoundException
- the path was not foundAccessDeniedException
- the access is deniedUnsupportedFeatureException
- the feature is not supportedAttributeNotFoundException
- the specified attribute was not foundpublic java.lang.Iterable<ExtendedAttribute> listExtendedAttributes(java.lang.String path) throws PathNotFoundException, AccessDeniedException, UnsupportedFeatureException
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
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
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)
mountPath
- the mount pathpublic void beforeUnmounting()
public void afterUnmounting()