|
TrueZIP Kernel 7.0-rc2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.truezip.fs.archive.FsArchiveFileSystem<E>
E - The type of the archive entries.@NotThreadSafe @DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) class FsArchiveFileSystem<E extends FsArchiveEntry>
A read/write virtual file system for archive entries.
| Nested Class Summary | |
|---|---|
private static class |
FsArchiveFileSystem.DefaultEntryTable<E extends FsArchiveEntry>
|
private static class |
FsArchiveFileSystem.MasterEntryTable<E extends FsArchiveEntry>
Splits a given path name into its parent path name and base name. |
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
|
private static class |
FsArchiveFileSystem.ZipOrTarEntryTable<E extends FsArchiveEntry>
|
| Field Summary | |
|---|---|
private EntryFactory<E> |
factory
|
private FsArchiveFileSystem.MasterEntryTable<E> |
master
|
private FsArchiveFileSystem.Splitter |
splitter
|
private boolean |
touched
Whether or not this file system has been modified (touched). |
private LinkedHashSet<FsArchiveFileSystemTouchListener<? super E>> |
touchListeners
|
| Constructor Summary | |
|---|---|
private |
FsArchiveFileSystem(EntryFactory<E> factory)
|
(package private) |
FsArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
Entry rootTemplate)
|
| Method Summary | ||
|---|---|---|
(package private) void |
addFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Adds the given listener to the set of archive file system listeners. |
|
(package private) E |
copy(E entry)
|
|
private void |
fix(FsEntryName 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) FsArchiveFileSystemEntry<E> |
getEntry(FsEntryName 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 |
isTouched()
Returns true if and only if this archive file system has been
modified since its time of creation. |
|
boolean |
isWritable(FsEntryName name)
|
|
Iterator<FsArchiveFileSystemEntry<E>> |
iterator()
|
|
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
|
newArchiveFileSystem(EntryFactory<AE> factory)
Returns a new archive file system and ensures its integrity. |
|
(package private) static
|
newArchiveFileSystem(EntryFactory<E> factory,
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. |
|
private FsArchiveFileSystemEntry<E> |
newEntryChecked(FsEntryName name,
Entry.Type type,
Entry template)
Returns a new file system entry for this (virtual) archive file system. |
|
private FsArchiveFileSystemEntry<E> |
newEntryUnchecked(FsEntryName name,
Entry.Type type,
Entry template)
Like newEntryChecked(path, type, null),
but wraps any CharConversionException in an
AssertionError. |
|
private static
|
newMasterEntryTable(FsArchiveFileSystemEntry<E> root,
int initialCapacity)
|
|
(package private) void |
removeFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
Removes the given listener from the set of archive file system listeners. |
|
void |
setReadOnly(FsEntryName name)
|
|
boolean |
setTime(FsEntryName name,
BitField<Entry.Access> types,
long value)
|
|
private void |
touch()
Ensures that the controller's data structures required to output entries are properly initialized and marks this (virtual) archive file system as touched. |
|
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. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final FsArchiveFileSystem.Splitter splitter
private final EntryFactory<E extends FsArchiveEntry> factory
private final FsArchiveFileSystem.MasterEntryTable<E extends FsArchiveEntry> master
private boolean touched
private LinkedHashSet<FsArchiveFileSystemTouchListener<? super E extends FsArchiveEntry>> touchListeners
| Constructor Detail |
|---|
private FsArchiveFileSystem(EntryFactory<E> factory)
FsArchiveFileSystem(EntryFactory<E> factory,
EntryContainer<E> archive,
@CheckForNull
Entry rootTemplate)
| Method Detail |
|---|
static <AE extends FsArchiveEntry> FsArchiveFileSystem<AE> newArchiveFileSystem(EntryFactory<AE> factory)
factory - the archive entry factory to use.
NullPointerException - If factory is null.
static <E extends FsArchiveEntry> FsArchiveFileSystem<E> newArchiveFileSystem(EntryFactory<E> factory,
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.
archive - The archive entry container to read the entries for
the population of the archive file system.factory - the archive entry factory to use.rootTemplate - The last modification time of the root of the populated
file system in milliseconds since the epoch.readOnly - If and only if true, any subsequent
modifying operation on the file system will result in a
FsReadOnlyArchiveFileSystemException.
NullPointerException - If container, factory or
rootTemplate are null.
IllegalArgumentException - If rootTemplate is an instance
of FsArchiveFileSystemEntry.
private static <E extends FsArchiveEntry> FsArchiveFileSystem.MasterEntryTable<E> newMasterEntryTable(FsArchiveFileSystemEntry<E> root,
int initialCapacity)
private void fix(FsEntryName 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.boolean isReadOnly()
true if and only if this archive file system is
read-only.
This method is provided for inheritance - the implementation in this
class always returns false.
boolean isTouched()
true if and only if this archive file system has been
modified since its time of creation.
private void touch()
throws FsArchiveFileSystemException
ArchiveReadOnlyExceptionn - If this (virtual) archive file system
is read only.
FsArchiveFileSystemException - If the listener vetoed the beforeTouch
operation for any reason.Set<FsArchiveFileSystemTouchListener<? super E>> getFsArchiveFileSystemTouchListeners()
final void addFsArchiveFileSystemTouchListener(FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.
final void removeFsArchiveFileSystemTouchListener(@Nullable
FsArchiveFileSystemTouchListener<? super E> listener)
listener - the listener for archive file system events.int getSize()
public Iterator<FsArchiveFileSystemEntry<E>> iterator()
iterator in interface Iterable<FsArchiveFileSystemEntry<E extends FsArchiveEntry>>@Nullable final FsArchiveFileSystemEntry<E> getEntry(FsEntryName name)
private FsArchiveFileSystemEntry<E> newEntryUnchecked(FsEntryName name,
Entry.Type type,
@CheckForNull
Entry template)
newEntryChecked(path, type, null),
but wraps any CharConversionException in an
AssertionError.
name - the archive file system entry name.type - the type of the archive file system entry to create.template - the nullable template for the archive file system entry
to create.
AssertionError - if a CharConversionException
occurs. The original exception is wrapped as its cause.
private FsArchiveFileSystemEntry<E> newEntryChecked(FsEntryName name,
Entry.Type type,
@CheckForNull
Entry template)
throws FsArchiveFileSystemException
name - the archive file system entry name.type - the type of the archive file system entry to create.template - the nullable template for the archive file system entry
to create.
FsArchiveFileSystemExceptionmknod(de.schlichtherle.truezip.fs.FsEntryName, de.schlichtherle.truezip.entry.Entry.Type, de.schlichtherle.truezip.util.BitField, de.schlichtherle.truezip.entry.Entry) final E copy(E entry)
public 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.
public 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.
ArchiveReadOnlyExceptionn - If this (virtual) archive file system
is read-only.
FsArchiveFileSystemException - If the operation fails for some other
reason.
public boolean setTime(FsEntryName name,
BitField<Entry.Access> types,
long value)
throws FsArchiveFileSystemException
FsArchiveFileSystemExceptionpublic boolean isWritable(FsEntryName name)
public void setReadOnly(FsEntryName name)
throws FsArchiveFileSystemException
FsArchiveFileSystemException
|
TrueZIP Kernel 7.0-rc2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||