E - The type of the archive entries.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) public class FsArchiveFileSystem<E extends FsArchiveEntry> extends Object implements Iterable<FsCovariantEntry<E>>
| Modifier and Type | Class and Description |
|---|---|
private static class |
FsArchiveFileSystem.EntryTable<E extends FsArchiveEntry> |
private class |
FsArchiveFileSystem.PathLink
TODO: This implementation yields a potential issue: The state of the
file system may be altered between the construction of an instance and
the call to the
FsArchiveFileSystem.PathLink.run() method, which may render the operation
illegal and corrupt the file system. |
private static class |
FsArchiveFileSystem.SegmentLink<E extends FsArchiveEntry>
A data class which represents a segment for use by
FsArchiveFileSystem.PathLink. |
private static class |
FsArchiveFileSystem.Splitter
Splits a given path name into its parent path name and base name.
|
| Modifier and Type | Field and Description |
|---|---|
private FsArchiveDriver<E> |
factory |
private FsArchiveFileSystem.EntryTable<E> |
master |
static int |
OVERHEAD_SIZE
The number of entries which can be additionally accomodated by
the internal hash map without resizing it, which is 64.
|
private static String |
ROOT_PATH |
private FsArchiveFileSystem.Splitter |
splitter |
private boolean |
touched
Whether or not this file system has been modified (touched).
|
private Set<FsArchiveFileSystemTouchListener<? super E>> |
touchListeners |
| Modifier | Constructor and Description |
|---|---|
private |
FsArchiveFileSystem(FsArchiveDriver<E> driver) |
(package private) |
FsArchiveFileSystem(FsArchiveDriver<E> driver,
EntryContainer<E> archive,
Entry rootTemplate) |
| Modifier and Type | Method and Description |
|---|---|
(package private) void |
addFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Adds the given listener to the set of archive file system listeners.
|
private void |
fix(String name)
Called from a constructor to fix the parent directories of the
file system entry identified by
name, ensuring that all
parent directories of the file system entry exist and that they
contain the respective base. |
(package private) FsCovariantEntry<E> |
getEntry(FsEntryName name)
Returns a covariant file system entry or
null if no file system
entry exists for the given name. |
(package private) Set<FsArchiveFileSystemTouchListener<? super E>> |
getFsArchiveFileSystemTouchListeners()
Returns a protective copy of the set of archive file system listeners.
|
(package private) int |
getSize() |
(package private) boolean |
isReadOnly()
Returns
true if and only if this archive file system is
read-only. |
(package private) boolean |
isWritable(FsEntryName name) |
Iterator<FsCovariantEntry<E>> |
iterator() |
(package private) FsArchiveFileSystemOperation<E> |
mknod(FsEntryName name,
Entry.Type type,
BitField<FsOutputOption> options,
Entry template)
Begins a transaction to create or replace and finally link a
chain of one or more archive entries for the given
path into
this archive file system. |
(package private) static <E extends FsArchiveEntry> |
newEmptyFileSystem(FsArchiveDriver<E> driver)
Returns a new empty archive file system and ensures its integrity.
|
private E |
newEntryChecked(String name,
Entry.Type type,
BitField<FsOutputOption> mknod,
Entry template)
Returns a new archive entry.
|
private E |
newEntryUnchecked(String name,
Entry.Type type,
BitField<FsOutputOption> mknod,
Entry template)
|
(package private) static <E extends FsArchiveEntry> |
newPopulatedFileSystem(FsArchiveDriver<E> driver,
EntryContainer<E> archive,
Entry rootTemplate,
boolean readOnly)
Returns a new archive file system which populates its entries from
the given
archive and ensures its integrity. |
(package private) void |
removeFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Removes the given listener from the set of archive file system listeners.
|
(package private) void |
setReadOnly(FsEntryName name) |
(package private) boolean |
setTime(FsEntryName name,
BitField<Entry.Access> types,
long value) |
(package private) boolean |
setTime(FsEntryName name,
Map<Entry.Access,Long> times) |
private void |
touch()
Marks this (virtual) archive file system as touched and notifies the
listener if and only if the touch status is changing.
|
(package private) void |
unlink(FsEntryName name)
If this method returns, the file system entry identified by the given
path has been successfully deleted from this archive file
system. |
private final FsArchiveDriver<E extends FsArchiveEntry> factory
private final FsArchiveFileSystem.EntryTable<E extends FsArchiveEntry> master
public static final int OVERHEAD_SIZE
private static final String ROOT_PATH
private final FsArchiveFileSystem.Splitter splitter
private boolean touched
private Set<FsArchiveFileSystemTouchListener<? super E extends FsArchiveEntry>> touchListeners
private FsArchiveFileSystem(FsArchiveDriver<E> driver)
FsArchiveFileSystem(FsArchiveDriver<E> driver, EntryContainer<E> archive, @CheckForNull Entry rootTemplate)
final void addFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.private void fix(String name)
name, ensuring that all
parent directories of the file system entry exist and that they
contain the respective base.
If a parent directory does not exist, it is created using an
unkown time as the last modification time - this is defined to be a
ghost directory.
If a parent directory does exist, the respective base is added
(possibly yet again) and the process is continued.name - the archive file system entry name.@Nullable final FsCovariantEntry<E> getEntry(FsEntryName name)
null 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
this file system.name - the name of the file system entry to look up.null if no file system
entry exists for the given name.Set<FsArchiveFileSystemTouchListener<? super E>> getFsArchiveFileSystemTouchListeners()
int getSize()
boolean isReadOnly()
true if and only if this archive file system is
read-only.
The implementation in the class FsArchiveFileSystem always
returns false.
boolean isWritable(FsEntryName name)
public Iterator<FsCovariantEntry<E>> iterator()
iterator in interface Iterable<FsCovariantEntry<E extends FsArchiveEntry>>FsArchiveFileSystemOperation<E> mknod(FsEntryName name, Entry.Type type, BitField<FsOutputOption> options, @CheckForNull Entry template) throws FsArchiveFileSystemException
path into
this archive file system.
To commit the transaction, you need to call
FsArchiveFileSystemOperation.run() on the returned object, which
will mark this archive file system as touched and set the last
modification time of the created and linked archive file system entries
to the system's current time at the moment of the call to this method.
name - the archive file system entry name.type - the type of the archive file system entry to create.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 archive 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.FsArchiveFileSystemOperation.run() method.NullPointerException - if path or type are
null.ArchiveReadOnlyExceptionn - If this archive file system is read
only.FsArchiveFileSystemException - If one of the following is true:
name contains characters which are not
supported by the file system.
FILE or DIRECTORY.
FsOutputOption.EXCLUSIVE is set or the entry is a
directory.
createParents is
false.
static <E extends FsArchiveEntry> FsArchiveFileSystem<E> newEmptyFileSystem(FsArchiveDriver<E> driver)
E - The type of the archive entries.driver - the archive driver to use.NullPointerException - If factory is null.private E newEntryChecked(String name, Entry.Type type, BitField<FsOutputOption> mknod, @CheckForNull Entry template) throws FsArchiveFileSystemException
name - the archive entry name.type - the type of the archive entry to create.template - the nullable template for the archive entry to create.FsArchiveFileSystemException - if a CharConversionException
occurs as its cause.mknod(de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.entry.Entry.Type, de.schlichtherle.truezip.util.BitField<de.schlichtherle.truezip.fs.FsOutputOption>, de.schlichtherle.truezip.entry.Entry)private E newEntryUnchecked(String name, Entry.Type type, BitField<FsOutputOption> mknod, @CheckForNull Entry template)
name - the archive entry name.type - the type of the archive entry to create.template - the nullable template for the archive entry to create.static <E extends FsArchiveEntry> FsArchiveFileSystem<E> newPopulatedFileSystem(FsArchiveDriver<E> driver, EntryContainer<E> archive, @CheckForNull Entry rootTemplate, boolean readOnly)
archive and ensures its integrity.
First, the entries from the archive are loaded into the file system.
Second, a root directory with the given last modification time is created and linked into the filesystem (so it's never loaded from the archive).
Finally, the file system integrity is checked and fixed: Any missing parent directories are created using the system's current time as their last modification time - existing directories will never be replaced.
Note that the entries in the file system are shared with the given
archive entry container.
E - The type of the archive entries.driver - the archive driver to use.archive - The archive entry container to read the entries for
the population of the archive file system.rootTemplate - The nullable template to use for the root entry of
the returned archive file system.
This must not be an instance of FsCovariantEntry.readOnly - If and only if true, any subsequent
modifying operation on the file system will result in a
FsReadOnlyArchiveFileSystemException.NullPointerException - If factory or archive are
null.final void removeFsArchiveFileSystemTouchListener(@Nullable FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.void setReadOnly(FsEntryName name) throws FsArchiveFileSystemException
FsArchiveFileSystemExceptionboolean setTime(FsEntryName name, BitField<Entry.Access> types, long value) throws FsArchiveFileSystemException
FsArchiveFileSystemExceptionboolean setTime(FsEntryName name, Map<Entry.Access,Long> times) throws FsArchiveFileSystemException
FsArchiveFileSystemExceptionprivate void touch()
throws FsArchiveFileSystemException
FsReadOnlyArchiveFileSystemException - If this (virtual) archive
file system is read only.FsArchiveFileSystemException - If the listener vetoed the beforeTouch
operation for any reason.void unlink(FsEntryName name) throws FsArchiveFileSystemException
path has been successfully deleted from this archive file
system.
If the file system entry is a directory, it must be empty for successful
deletion.name - the archive file system entry name.FsReadOnlyArchiveFileSystemException - If this (virtual) archive
file system is read-only.FsArchiveFileSystemException - If the operation fails for some other
reason.Copyright © 2004-2011 Schlichtherle IT Services. All Rights Reserved.