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, unlockFile
public java.lang.Iterable<EntityInfo> listDirectory(java.lang.String path) throws NotADirectoryException, PathNotFoundException
FileSystem
listDirectory
in class FileSystem
path
- the pathNotADirectoryException
- the path is not a directoryPathNotFoundException
- the path could not be foundpublic 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 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
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)public void createDirectory(java.lang.String path) throws PathNotFoundException, DestinationAlreadyExistsException
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)public 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 setLength(FileHandle fh, long length)
FileSystem
setLength
in class FileSystem
fh
- 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 FileSystem
fh
- the file handle.buffer
- the buffer to writeoffset
- the offset within the filepublic void flush(FileHandle fh)
FileSystem
flush
in class FileSystem
fh
- the file handlepublic void close(FileHandle fh)
FileSystem
close
in class FileSystem
fh
- the file handlepublic void deleteFile(java.lang.String file) throws PathNotFoundException
FileSystem
deleteFile
in class FileSystem
file
- the filePathNotFoundException
- the file could not be foundpublic void deleteDirectoryRecursively(java.lang.String directory) throws PathNotFoundException
FileSystem
deleteDirectoryRecursively
in class FileSystem
directory
- the directoryPathNotFoundException
- the directory could not be foundpublic java.lang.String getVolumeName()
FileSystem
getVolumeName
in class FileSystem
public java.lang.String getFileSystemName()
FileSystem
getFileSystemName
in class FileSystem
public void setLastAccessTime(java.lang.String path, long atime) throws PathNotFoundException
FileSystem
setLastAccessTime
in class FileSystem
path
- 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
FileSystem
setLastModificationTime
in class FileSystem
path
- 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
FileSystem
setCreationTime
in class FileSystem
path
- the pathcreationTime
- the creation time (unix timestamp)PathNotFoundException
- the path could not be found.public 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 long getFreeBlockAvailableCount()
FileSystem
getFreeBlockAvailableCount
in class FileSystem