|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.ArchiveFileSystem
final class ArchiveFileSystem
This class implements a virtual file system of archive entries for use by the archive controller provided to the constructor.
WARNING:This class is not thread safe!
All calls to non-static methods must be synchronized on the
respective ArchiveController object!
ZipFileSystem)| Nested Class Summary | |
|---|---|
private static class |
ArchiveFileSystem.AbstractDelta
|
(package private) static class |
ArchiveFileSystem.ArchiveFileSystemException
This exception is thrown when a client application tries to perform an illegal operation on an archive file system. |
(package private) static class |
ArchiveFileSystem.ArchiveReadOnlyException
This exception is thrown when a client tries to modify a read only virtual archive file system. |
(package private) static interface |
ArchiveFileSystem.Delta
This interface encapsulates the methods required to begin and commit a simplified transaction (a delta) on this virtual archive file system. |
private class |
ArchiveFileSystem.LinkDelta
A simple transaction for creating (and hence probably replacing) and linking an entry in this virtual archive file system. |
| Field Summary | |
|---|---|
private ArchiveFileSystemController |
controller
The controller that this filesystem belongs to. |
private Map |
master
The map of ArchiveEntries in this file system. |
private boolean |
readOnly
The read only status of this file system. |
private ArchiveEntry |
root
The archive entry for the virtual root of this file system. |
private static String |
ROOT_DIRECTORY_NAME
Denotes the entry name of the virtual root directory as a valid directory entry name. |
private String[] |
split
For use by split only! |
private long |
touched
The number of times this file system has been modified (touched). |
| Fields inherited from interface de.schlichtherle.io.Entry |
|---|
ROOT_NAME, SEPARATOR, SEPARATOR_CHAR |
| Constructor Summary | |
|---|---|
ArchiveFileSystem(ArchiveFileSystemController controller)
Creates a new archive file system and ensures its integrity. |
|
ArchiveFileSystem(ArchiveFileSystemController controller,
InputArchive archive,
long rootTime,
boolean readOnly)
Mounts the archive file system from archive and ensures its
integrity. |
|
| Method Summary | |
|---|---|
(package private) boolean |
canWrite(String entryName)
|
private ArchiveEntry |
createArchiveEntry(String entryName)
Like createArchiveEntry(java.lang.String, de.schlichtherle.io.archive.spi.ArchiveEntry), but throws an
AssertionError instead of
CharConversionException. |
private ArchiveEntry |
createArchiveEntry(String entryName,
ArchiveEntry blueprint)
Creates an archive entry which is going to be linked into this virtual archive file system in the near future. |
(package private) void |
delete(String entryName)
|
(package private) boolean |
exists(String entryName)
|
private void |
fixParents(ArchiveEntry entry)
Called from a constructor to fix the parent directories of entry, ensuring that all parent directories of the entry
exist and that they contain the respective child. |
private void |
fixParents(String entryName)
|
(package private) ArchiveEntry |
get(String entryName)
Looks up the specified entry in the file system and returns it or null if not existent. |
(package private) Enumeration |
getArchiveEntries()
Returns an enumeration of all ArchiveEntry instances
in this file system. |
(package private) Icon |
getClosedIcon(String entryName)
|
private String |
getEntryName(ArchiveEntry entry)
|
(package private) Icon |
getOpenIcon(String entryName)
|
(package private) ArchiveEntry |
getRoot()
Returns the virtual root directory of this file system. |
(package private) boolean |
isDirectory(String entryName)
|
(package private) boolean |
isFile(String entryName)
|
private static boolean |
isLegalEntryName(String entryName)
Checks whether the given entry entryName is a legal entry name. |
(package private) boolean |
isReadOnly()
Indicates whether this file system is read only or not. |
(package private) static boolean |
isRoot(String entryName)
Returns true iff the given entry name refers to the
virtual root directory within this controller. |
(package private) boolean |
isTouched()
Indicates whether this file system has been modified since its time of creation or the last call to resetTouched(). |
(package private) long |
lastModified(String entryName)
|
(package private) long |
length(String entryName)
|
(package private) ArchiveFileSystem.Delta |
link(String entryName,
boolean createParents)
Equivalent to link(entryName, createParents, null). |
(package private) ArchiveFileSystem.Delta |
link(String entryName,
boolean createParents,
ArchiveEntry template)
Begins a "create and link entry" transaction to ensure that either a new entry for the given entryName will be created or an
existing entry is replaced within this virtual archive file system. |
(package private) String[] |
list(String entryName)
|
(package private) String[] |
list(String entryName,
FilenameFilter filenameFilter,
File dir)
|
(package private) File[] |
listFiles(String entryName,
FileFilter fileFilter,
File dir,
FileFactory factory)
|
(package private) File[] |
listFiles(String entryName,
FilenameFilter filenameFilter,
File dir,
FileFactory factory)
|
(package private) void |
mkdir(String entryName,
boolean createParents)
|
(package private) boolean |
setLastModified(String entryName,
long time)
|
(package private) boolean |
setReadOnly(String entryName)
|
private String[] |
split(String entryName)
Splits the given entry name in a parent entry name and a base name. |
(package private) static String[] |
split(String entryName,
String[] result)
|
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. |
private void |
unlink(String entryName)
If this method returns, the entry identified by the given entryName has been successfully deleted from the virtual
archive file system. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final String ROOT_DIRECTORY_NAME
This constant cannot be used for identity comparison!
private final ArchiveFileSystemController controller
private final boolean readOnly
private Map master
Note that the ArchiveEntries in this map are shared with the
InputArchive object provided to this class' constructor.
private final ArchiveEntry root
private long touched
private final String[] split
split only!
| Constructor Detail |
|---|
ArchiveFileSystem(ArchiveFileSystemController controller)
throws IOException
controller - The controller which will use this file system.
This constructor will finally call
ArchiveFileSystemController.touch() once it has fully
initialized this instance.
IOException
ArchiveFileSystem(ArchiveFileSystemController controller,
InputArchive archive,
long rootTime,
boolean readOnly)
archive and ensures its
integrity.
First, a root directory with the given last modification time is
created - it's never loaded from the archive!
Then the entries from the archive are loaded into the file system and
its integrity is checked:
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 this file system are shared with
archive.
controller - The controller which will use this file system.
This constructor will solely use the controller as a factory
to create missing archive entries using
ArchiveFileSystemController.createArchiveEntry(java.lang.String, de.schlichtherle.io.archive.spi.ArchiveEntry).archive - The archive to mount the file system from.rootTime - The last modification time of the root of the mounted
file system in milliseconds since the epoch.readOnly - If and only if true, any subsequent
modifying operation will result in a
ArchiveFileSystem.ArchiveReadOnlyException.| Method Detail |
|---|
private String getEntryName(ArchiveEntry entry)
private static boolean isLegalEntryName(String entryName)
".") or the dot-dot directory
("..") or any of their descendants.
private void fixParents(ArchiveEntry entry)
entry, ensuring that all parent directories of the entry
exist and that they contain the respective child.
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 child is added
(possibly yet again) and the process is continued.
private void fixParents(String entryName)
private String[] split(String entryName)
entryName - The name of the entry which's parent entry name and
base name are to be returned.
split array, which will hold at least two strings:
entryName is empty or equals
SEPARATOR, this is null.
Otherwise, this contains the parent name of the entry and
always ends with an SEPARATOR.
entryName is empty or equals
SEPARATOR, this is an empty string.
Otherwise, this contains the base name of the entry and
never contains an SEPARATOR.
NullPointerException - If entryName is
null.
static String[] split(String entryName,
String[] result)
boolean isReadOnly()
false.
boolean isTouched()
resetTouched().
private void touch()
throws IOException
ArchiveReadOnlyExceptionn - If this virtual archive file system
is read only.
IOException - If setting up the required data structures in the
controller fails for some reason.Enumeration getArchiveEntries()
ArchiveEntry instances
in this file system.
ArchiveEntry getRoot()
static boolean isRoot(String entryName)
true iff the given entry name refers to the
virtual root directory within this controller.
ArchiveEntry get(String entryName)
null if not existent.
ArchiveFileSystem.Delta link(String entryName,
boolean createParents)
throws ArchiveFileSystem.ArchiveFileSystemException
link(entryName, createParents, null).
ArchiveFileSystem.ArchiveFileSystemException
ArchiveFileSystem.Delta link(String entryName,
boolean createParents,
ArchiveEntry template)
throws ArchiveFileSystem.ArchiveFileSystemException
entryName will be created or an
existing entry is replaced within this virtual archive file system.
This is the first step of a two-step process to create an archive entry
and link it into this virtual archive file system.
To commit the transaction, call ArchiveFileSystem.LinkDelta.commit() on the returned object
after you have successfully conducted the operations which compose the
transaction.
Upon a commit operation, the last modification time of
the newly created and linked entries will be set to the system's
current time at the moment the transaction has begun and the file
system will be marked as touched at the moment the transaction has
been committed.
Note that there is no rollback operation: After this method returns, nothing in the virtual file system has changed yet and all information required to commit the transaction is contained in the returned object. Hence, if the operations which compose the transaction fails, the returned object may be safely collected by the garbage collector,
entryName - The relative path name of the entry to create or replace.createParents - If true, any non-existing parent
directory will be created in this file system with its last
modification time set to the system's current time.template - If not null, then the newly created or
replaced entry shall inherit as much properties from this
instance as possible (with the exception of the name).
This is typically used for archive copy operations and requires
some support by the archive driver.
ArchiveFileSystem.LinkDelta.commit() method in order to commit
link the newly created entry into this virtual archive file
system.
ArchiveReadOnlyExceptionn - If this virtual archive file system
is read only.
ArchiveFileSystem.ArchiveFileSystemException - If one of the following is true:
entryName contains characters which are not
supported by the archive file.
/)
and its entry does already exist within this file system.
createParents is false.
private ArchiveEntry createArchiveEntry(String entryName,
ArchiveEntry blueprint)
throws CharConversionException
entryName - The path name of the entry to create or replace.
This must be a relative path name.blueprint - If not null, then the newly created entry
shall inherit as much attributes from this object as possible
(with the exception of the name).
This is typically used for archive copy operations and requires
some support by the archive driver.
ArchiveEntry created by the archive driver and
properly initialized with meta data.
CharConversionException - If entryName contains
characters which are not supported by the archive file.private ArchiveEntry createArchiveEntry(String entryName)
createArchiveEntry(java.lang.String, de.schlichtherle.io.archive.spi.ArchiveEntry), but throws an
AssertionError instead of
CharConversionException.
AssertionError - If a CharConversionException occurs.
private void unlink(String entryName)
throws IOException
entryName has been successfully deleted from the virtual
archive file system.
If the entry is a directory, it must be empty for successful deletion.
ArchiveReadOnlyExceptionn - If the virtual archive file system is
read only.
ArchiveIllegalOperationException - If the operation failed for
any other reason.
IOExceptionboolean exists(String entryName)
boolean isFile(String entryName)
boolean isDirectory(String entryName)
Icon getOpenIcon(String entryName)
Icon getClosedIcon(String entryName)
boolean canWrite(String entryName)
boolean setReadOnly(String entryName)
long length(String entryName)
long lastModified(String entryName)
boolean setLastModified(String entryName,
long time)
throws IOException
IOExceptionString[] list(String entryName)
String[] list(String entryName,
FilenameFilter filenameFilter,
File dir)
File[] listFiles(String entryName,
FilenameFilter filenameFilter,
File dir,
FileFactory factory)
File[] listFiles(String entryName,
FileFilter fileFilter,
File dir,
FileFactory factory)
void mkdir(String entryName,
boolean createParents)
throws IOException
IOException
void delete(String entryName)
throws IOException
IOException
|
TrueZIP 6.8.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||