public class MemoryFs extends FileSystem
| Constructor and Description |
|---|
MemoryFs() |
| Modifier and Type | Method and Description |
|---|---|
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 |
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.
|
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.
|
long |
getTotalBlockCount()
Returns the number of total blocks.
|
java.lang.String |
getVolumeName()
Returns the volume name.
|
boolean |
isCaseSensitive()
Returns true if the pathes are case sensitive
|
java.lang.Iterable<EntityInfo> |
listDirectory(java.lang.String path)
Reads a given directory and returns an iterator.
|
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 |
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 |
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 |
write(FileHandle fh,
java.nio.ByteBuffer buffer,
long offset)
(Over-)writes the buffer into the specified file handle.
|
afterUnmounting, beforeMounting, beforeUnmounting, createHardLink, createSymbolicLink, delete, getExtendedAttribute, getFilesFreeCount, getMaxPathLength, getMountPath, getNumberOfFilesInDirectory, getTotalFilesCount, getUnixPermissions, getVolumeSerialNumber, getWindowsAttributes, isCompressed, isReadOnly, listExtendedAttributes, lockFile, pathExists, removeExtendedAttribute, setExtendedAttribute, setUnixPermissions, setWindowsAttributes, supportsUnicodeFilenames, unlockFilepublic java.lang.Iterable<EntityInfo> listDirectory(java.lang.String path) throws NotADirectoryException, PathNotFoundException
FileSystemlistDirectory in class FileSystempath - the pathNotADirectoryException - the path is not a directoryPathNotFoundException - the path could not be foundpublic 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 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
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)public void createDirectory(java.lang.String path)
throws PathNotFoundException,
DestinationAlreadyExistsException
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)public 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 setLength(FileHandle fh, long length)
FileSystemsetLength in class FileSystemfh - the file handlelength - the new file size in bytespublic void write(FileHandle fh, java.nio.ByteBuffer buffer, long offset)
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 filepublic void flush(FileHandle fh)
FileSystemflush in class FileSystemfh - the file handlepublic void close(FileHandle fh)
FileSystemclose in class FileSystemfh - the file handlepublic void deleteFile(java.lang.String file)
throws PathNotFoundException
FileSystemdeleteFile in class FileSystemfile - the filePathNotFoundException - the file could not be foundpublic void deleteDirectoryRecursively(java.lang.String directory)
throws PathNotFoundException
FileSystemdeleteDirectoryRecursively in class FileSystemdirectory - the directoryPathNotFoundException - the directory could not be foundpublic java.lang.String getVolumeName()
FileSystemgetVolumeName in class FileSystempublic java.lang.String getFileSystemName()
FileSystemgetFileSystemName in class FileSystempublic void setLastAccessTime(java.lang.String path,
long atime)
throws PathNotFoundException
FileSystemsetLastAccessTime in class FileSystempath - the pathatime - the last access time (unix timestamp)PathNotFoundException - the path could not be found.public void setLastModificationTime(java.lang.String path,
long mtime)
throws PathNotFoundException
FileSystemsetLastModificationTime in class FileSystempath - the pathmtime - the last modification time (unix timestamp)PathNotFoundException - the path could not be found.public void setCreationTime(java.lang.String path,
long creationTime)
throws PathNotFoundException
FileSystemsetCreationTime in class FileSystempath - the pathcreationTime - the creation time (unix timestamp)PathNotFoundException - the path could not be found.public boolean isCaseSensitive()
FileSystemisCaseSensitive in class FileSystempublic int getBlockSize()
FileSystemgetBlockSize in class FileSystempublic long getTotalBlockCount()
FileSystemgetTotalBlockCount in class FileSystempublic long getFreeBlockCount()
FileSystemgetFreeBlockCount in class FileSystempublic long getFreeBlockAvailableCount()
FileSystemgetFreeBlockAvailableCount in class FileSystem