public final class Filesystem extends Object implements FilesystemType
The basic filesystem implementation.
This implementation supports loading of archives from a single directory, or from the classpath.
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the given filesystem.
|
void |
createDirectory(PathVirtual path)
Create a directory in the virtual filesystem at
path. |
boolean |
exists(PathVirtual path) |
long |
getFileSize(PathVirtual path) |
Calendar |
getModificationTime(PathVirtual path) |
Deque<com.io7m.jfunctional.Pair<PathReal,PathVirtual>> |
getMountedArchives() |
boolean |
isDirectory(PathVirtual path) |
boolean |
isFile(PathVirtual path) |
SortedSet<String> |
listDirectory(PathVirtual path) |
static FilesystemType |
makeWithArchiveDirectory(com.io7m.jlog.LogUsableType log,
PathReal archives)
Construct a filesystem using
archives as the location of the
archive directory. |
static FilesystemType |
makeWithoutArchiveDirectory(com.io7m.jlog.LogUsableType log)
Construct a filesystem without an archive directory.
|
void |
mountArchive(String archive,
PathVirtual mount)
Mount the archive
archive at mount. |
void |
mountArchiveFromAnywhere(File archive,
PathVirtual mount)
Mount the archive
archive at mount. |
void |
mountClasspathArchive(Class<?> c,
PathVirtual mount)
Mount the archive containing class
c at mount. |
InputStream |
openFile(PathVirtual path)
Open the file at
path. |
void |
unmount(PathVirtual mount)
Unmounts the most recently mounted archive at
mount. |
void |
updateModificationTime(PathVirtual path,
Calendar t)
Updates the modification time of the object at
path to
t. |
public static FilesystemType makeWithArchiveDirectory(com.io7m.jlog.LogUsableType log, PathReal archives)
Construct a filesystem using archives as the location of the
archive directory.
log - The log interfacearchives - The archive directorypublic static FilesystemType makeWithoutArchiveDirectory(com.io7m.jlog.LogUsableType log)
Construct a filesystem without an archive directory. A filesystem constructed in this manner may only access archives on the classpath.
log - The log interfacepublic void close()
throws FilesystemError
FSCapabilityCloseTypeClose the given filesystem. This:
Due to archives being closed, the state of any streams associated with files in the filesystem will become undefined.
close in interface FSCapabilityCloseTypeFilesystemError - If a filesystem error occurs.public void createDirectory(PathVirtual path) throws FilesystemError
FSCapabilityCreateDirectoryType
Create a directory in the virtual filesystem at path.
createDirectory in interface FSCapabilityCreateDirectoryTypepath - The path.FilesystemError - If:
path is not a directory.public boolean exists(PathVirtual path) throws FilesystemError
exists in interface FSCapabilityReadTypepath - The path.true iff path exists.FilesystemError - If a filesystem error occurs.public long getFileSize(PathVirtual path) throws FilesystemError
getFileSize in interface FSCapabilityReadTypepath - The path.path.FilesystemError - If:
path.path is not a filepublic Calendar getModificationTime(PathVirtual path) throws FilesystemError
getModificationTime in interface FSCapabilityReadTypepath - The path.path.FilesystemError - If:
r.public Deque<com.io7m.jfunctional.Pair<PathReal,PathVirtual>> getMountedArchives()
getMountedArchives in interface FSCapabilityMountSnapshotTypepublic boolean isDirectory(PathVirtual path) throws FilesystemError
isDirectory in interface FSCapabilityReadTypepath - The path.true iff path exists and is a
directory.FilesystemError - If a filesystem error occurs.public boolean isFile(PathVirtual path) throws FilesystemError
isFile in interface FSCapabilityReadTypepath - The path.true iff path exists and is a file.FilesystemError - If a filesystem error occurs.public SortedSet<String> listDirectory(PathVirtual path) throws FilesystemError
listDirectory in interface FSCapabilityReadTypepath - The path.path.FilesystemError - If:
path.path is not a directorypublic void mountArchive(String archive, PathVirtual mount) throws FilesystemError
FSCapabilityMountDirectoryType
Mount the archive archive at mount. The path
specified by mount is required to refer to an existing
directory.
If the directory at mount exists but was not explicitly
created with FSCapabilityCreateDirectoryType.createDirectory(PathVirtual), then the
mountArchive function first calls
FSCapabilityCreateDirectoryType.createDirectory(PathVirtual) to mark mount as
explicitly created, and then attempts to mount the archive as normal.
mountArchive in interface FSCapabilityMountDirectoryTypearchive - The archive to mount.mount - The mount point for the archive.FilesystemError - If a filesystem error occurs.public void mountArchiveFromAnywhere(File archive, PathVirtual mount) throws FilesystemError
FSCapabilityMountAnywhereType
Mount the archive archive at mount. The path
specified by mount is required to refer to an existing
directory.
If the directory at mount exists but was not explicitly
created with FSCapabilityCreateDirectoryType.createDirectory(PathVirtual), then the
mountArchive function first calls
FSCapabilityCreateDirectoryType.createDirectory(PathVirtual) to mark mount as
explicitly created, and then attempts to mount the archive as normal.
mountArchiveFromAnywhere in interface FSCapabilityMountAnywhereTypearchive - The archive to mount.mount - The mount point for the archive.FilesystemError - If a filesystem error occurs.public void mountClasspathArchive(Class<?> c, PathVirtual mount) throws FilesystemError
FSCapabilityMountClasspathType
Mount the archive containing class c at mount.
The path specified by mount is required to refer to an
existing directory.
If the directory at mount exists but was not explicitly
created with FSCapabilityCreateDirectoryType.createDirectory(PathVirtual), then the
mountArchive function first calls
FSCapabilityCreateDirectoryType.createDirectory(PathVirtual) to mark mount as
explicitly created, and then attempts to mount the archive as normal.
mountClasspathArchive in interface FSCapabilityMountClasspathTypec - A class appearing in one of the archives on the classpath.mount - The mount point for the archive.FilesystemError - If a filesystem error occurs.public InputStream openFile(PathVirtual path) throws FilesystemError
FSCapabilityReadType
Open the file at path.
openFile in interface FSCapabilityReadTypepath - The path.FilesystemError - If:
path.path is not a filepublic void unmount(PathVirtual mount) throws FilesystemError
FSCapabilityUnmountType
Unmounts the most recently mounted archive at mount. If
another archive is mounted at a directory contained within the archive
that would be unmounted, the operation fails.
unmount in interface FSCapabilityUnmountTypemount - The mount point.FilesystemError - If a filesystem error occurs.public void updateModificationTime(PathVirtual path, Calendar t) throws FilesystemError
FSCapabilityUpdateTimeType
Updates the modification time of the object at path to
t.
updateModificationTime in interface FSCapabilityUpdateTimeTypepath - The mount point.t - The requested time.FilesystemError - If a filesystem error occursCopyright © 2015 <code@io7m.com> http://io7m.com