E - The type of the archive entries.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public abstract class FsArchiveController<E extends FsArchiveEntry> extends FsController<FsConcurrentModel>
Each instance of this class manages an archive file - the target file - in order to allow random access to it as if it were a regular directory in its parent file system.
Note that in general all of the methods in this class are reentrant on exceptions. This is important because client applications may repeatedly call them. Of course, depending on the calling context, some or all of the archive file's data may be lost in this case.
| Modifier and Type | Class and Description |
|---|---|
private class |
FsArchiveController.Input |
private class |
FsArchiveController.Output |
private static class |
FsArchiveController.ProxyEntry |
| Modifier and Type | Field and Description |
|---|---|
private static BitField<FsOutputOption> |
AUTO_MOUNT_OPTIONS |
private static Logger |
logger |
private FsConcurrentModel |
model |
private static BitField<FsSyncOption> |
UNLINK_SYNC_OPTIONS |
| Modifier | Constructor and Description |
|---|---|
protected |
FsArchiveController(FsConcurrentModel model)
Constructs a new basic archive controller.
|
| Modifier and Type | Method and Description |
|---|---|
(package private) FsArchiveFileSystem<E> |
autoMount() |
(package private) abstract FsArchiveFileSystem<E> |
autoMount(boolean autoCreate,
BitField<FsOutputOption> options)
Returns the (virtual) archive file system mounted from the target
archive file.
|
(package private) abstract boolean |
autoSync(FsEntryName name,
Entry.Access intention)
Synchronizes the archive file only if the archive file has new data for
the file system entry with the given path path.
|
FsEntry |
getEntry(FsEntryName name)
Returns a file system entry or
null if no file system entry
exists for the given name. |
InputSocket<?> |
getInputSocket(FsEntryName name,
BitField<FsInputOption> options)
Returns an input socket for reading the contents of the file system
entry addressed by the given name from the file system.
|
(package private) abstract InputSocket<?> |
getInputSocket(String name) |
FsConcurrentModel |
getModel()
Returns the file system model.
|
(package private) abstract OutputSocket<?> |
getOutputSocket(E entry) |
OutputSocket<?> |
getOutputSocket(FsEntryName name,
BitField<FsOutputOption> options,
Entry template)
Returns an output socket for writing the contents of the entry addressed
by the given name to the file system.
|
boolean |
isReadable(FsEntryName name) |
boolean |
isReadOnly() |
boolean |
isWritable(FsEntryName name) |
void |
mknod(FsEntryName name,
Entry.Type type,
BitField<FsOutputOption> options,
Entry template)
Creates or replaces and finally links a chain of one or more entries
for the given entry
name into the file system. |
void |
setReadOnly(FsEntryName name) |
boolean |
setTime(FsEntryName name,
BitField<Entry.Access> types,
long value)
Makes an attempt to set the last access time of all types in the given
bit field for the file system entry with the given name.
|
void |
unlink(FsEntryName name) |
equals, getClosedIcon, getOpenIcon, getParent, hashCode, sync, sync, toStringprivate static final Logger logger
private static final BitField<FsOutputOption> AUTO_MOUNT_OPTIONS
private static final BitField<FsSyncOption> UNLINK_SYNC_OPTIONS
private final FsConcurrentModel model
protected FsArchiveController(FsConcurrentModel model)
model - the non-null archive model.public final FsConcurrentModel getModel()
FsControllergetModel in class FsController<FsConcurrentModel>final FsArchiveFileSystem<E> autoMount() throws IOException
IOExceptionabstract FsArchiveFileSystem<E> autoMount(boolean autoCreate, BitField<FsOutputOption> options) throws IOException
Warning: Either the read or the write lock of this controller must be acquired while this method is called! If only a read lock is acquired, but a write lock is required, this method will temporarily release all locks, so any preconditions must be checked again upon return to protect against concurrent modifications!
autoCreate - If the archive file does not exist and this is
true, a new file system with only a (virtual) root
directory is created with its last modification time set to the
system's current time.null is never returned.IOExceptionpublic final boolean isReadOnly()
throws IOException
isReadOnly in class FsController<FsConcurrentModel>IOExceptionpublic final FsEntry getEntry(FsEntryName name) throws IOException
FsControllernull if no file system entry
exists for the given name.
Modifying the returned object graph is either not supported (i.e. throws
an UnsupportedOperationException) or does not show any
effect on the file system.getEntry in class FsController<FsConcurrentModel>name - the name of the file system entry to look up.null if no file system entry
exists for the given name.IOException - on any I/O error.public final boolean isReadable(FsEntryName name) throws IOException
isReadable in class FsController<FsConcurrentModel>IOExceptionpublic final boolean isWritable(FsEntryName name) throws IOException
isWritable in class FsController<FsConcurrentModel>IOExceptionpublic final void setReadOnly(FsEntryName name) throws IOException
setReadOnly in class FsController<FsConcurrentModel>IOExceptionpublic final boolean setTime(FsEntryName name, BitField<Entry.Access> types, long value) throws IOException
FsControllerfalse is returned or an IOException is thrown, then
still some of the last access times may have been set.
In other words, this is not an atomic operation if multiple access types
are given.
To make this operation atomic, set the last access time for a single
type only.setTime in class FsController<FsConcurrentModel>name - the file system entry name.types - the access typesvalue - the last access time.true if and only if setting the access time for all
types in types succeeded.IOException - on any I/O error.public final InputSocket<?> getInputSocket(FsEntryName name, BitField<FsInputOption> options)
FsControllergetInputSocket in class FsController<FsConcurrentModel>name - the file system entry name.options - the input options.InputSocket.abstract InputSocket<?> getInputSocket(String name) throws IOException
IOExceptionpublic final OutputSocket<?> getOutputSocket(FsEntryName name, BitField<FsOutputOption> options, @CheckForNull Entry template)
FsControllertemplate is not null, then the output entry shall
have as many of its properties copied as reasonable, e.g. the last
modification time.getOutputSocket in class FsController<FsConcurrentModel>name - a file system entry name.options - a bit field of output options.template - a nullable template for the properties of the output
entry.OutputSocket.abstract OutputSocket<?> getOutputSocket(E entry) throws IOException
IOExceptionpublic final void mknod(FsEntryName name, Entry.Type type, BitField<FsOutputOption> options, @CheckForNull Entry template) throws IOException
FsControllername into the file system.mknod in class FsController<FsConcurrentModel>name - the file system entry name.type - the file system entry type.options - the file system output options.
If CREATE_PARENTS is set, any missing parent directories
will be created and linked into this file system with its last
modification time set to the system's current time.template - if not null, then the file system entry
at the end of the chain shall inherit as much properties from
this entry as possible - with the exception of its name and type.IOException - on any I/O error, including but not limited to these
reasons:
name contains characters which are not
supported by the file system.
FsOutputOption.EXCLUSIVE is set or the entry is a
directory.
createParents is
false.
public void unlink(FsEntryName name) throws IOException
unlink in class FsController<FsConcurrentModel>IOExceptionabstract boolean autoSync(FsEntryName name, @CheckForNull Entry.Access intention) throws FsSyncException, FsException
Warning: As a side effect, all data structures may get reset (filesystem, entries, streams, etc.)! This method may require synchronization on the write lock!
name - the non-null entry name.intention - the intended operation on the entry. If null,
a pure file system operation with no I/O is intended.IOException - if any exceptional condition occurs
throughout the synchronization of the target archive file.FsSyncExceptionFsExceptionFsController.sync(de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsSyncOption>)Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.