|
TrueZIP File* 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.File
de.schlichtherle.truezip.file.TFile
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class) @Immutable public final class TFile
A replacement for its subclass which provides transparent read/write access
to archive files and their entries as if they were (virtual) directories and
files.
This class extends File so that it can be used with a
FileSystemView.
This class provides some convenient copy methods which work much faster and more reliable than the naive read-then-write-in-a-loop approach for individual files and its recursive companion for directory trees. These copy methods fall into the following categories:
IOException on
failure.
The exception hierarchy is fine grained enough to let an application
differentiate between access restrictions, input exceptions and output
exceptions.
The method names have been modelled after the Unix cp -p
utility.
None of these methods does recursive copying, however.
cat.
cat(java.io.InputStream, java.io.OutputStream)
method is the core copy engine for all these methods.
It performs the data transfer from an input stream to an output stream.
When used with unbuffered input and output stream
implementations, it delivers the same performance as the transfer
method in the package java.nio.
If data is copied from an archive file to another archive file of the same type, some of the copy methods use a feature called Direct Data Copying (DDC) to achieve best performance: DDC copies the raw data from the source archive entry to the destination archive entry without the need to temporarily reproduce, copy and process the original data again.
The benefits of this feature are archive driver specific: In case of ZIP compatible files with compressed entries, it avoids the need to inflate the data from the source entry just to deflate it again for the destination entry. In case of TAR compatible files, it avoids the need to create an additional temporary file, but shows no impact otherwise (the TAR file format doesn't support compression).
Whenever an archive file suffix is recognized in a path, this class treats the corresponding file or directory as a prospective archive file. The word "prospective" suggests that just because a file is named archive.zip it isn't necessarily a valid ZIP file. In fact, it could be anything, even a plain old directory in the OS file system!
Such an invalid archive file is called a false positive archive file. TrueZIP correctly identifies all types of false positive archive files by performing a recursive look up operation for the first parent file system where the given archive file actually exists and treats it according to the true state of this entity.
The following table shows how certain methods in this class behave, depending upon an archive file's path and its true state in the first parent file system where it actually exists.
| Path | True State | isArchive()1 |
isDirectory() |
isFile() |
exists() |
length()2 |
|---|---|---|---|---|---|---|
| archive.zip3 | Valid ZIP file | true |
true |
false |
true |
0 |
| archive.zip | False positive: Regular directory | true |
true |
false |
true |
? |
| archive.zip | False positive: Regular file | true |
false |
true |
true |
? |
| archive.zip | False positive: Regular special file | true |
false |
false |
true |
? |
| archive.zip | TFile or directory does not exist | true |
false |
false |
false |
0 |
| archive.tzp4 | Valid RAES encrypted ZIP file with valid key (e.g. password) | true |
true |
false |
true |
0 |
| archive.tzp | Valid RAES encrypted ZIP file with unknown key5 | true |
false |
false |
true |
? |
| archive.tzp | False positive: Regular directory | true |
true |
false |
true |
? |
| archive.tzp | False positive: Regular file | true |
false |
true |
true |
? |
| archive.tzp | False positive: Regular special file | true |
false |
false |
true |
? |
| archive.tzp | TFile or directory does not exist | true |
false |
false |
false |
0 |
| other | Regular directory | false |
true |
false |
true |
? |
| other | Regular file | false |
false |
true |
true |
? |
| other | Regular special file | false |
false |
false |
true |
? |
| other | TFile or directory does not exist | false |
false |
false |
false |
0 |
isArchive() doesn't check the true state of the file - it just
looks at its path: If the path ends with a configured archive file
suffix, isArchive() always returns true.
length() always returns 0 if the path denotes a
valid archive file.
Otherwise, the return value of length() depends on the
platform and file system, which is indicated by ?.
For regular directories on Windows/NTFS for example, the return value
would be 0.
isDirectory() and isFile()
return false, while exists() returns true.
| Field Summary | |
|---|---|
private FsController<?> |
controller
This refers to the file system controller if and only if this file is located within a federated file system, otherwise it's null. |
private static TArchiveDetector |
defaultDetector
|
private File |
delegate
The delegate is used to implement the behaviour of the file system operations in case this instance represents neither an archive file nor an entry in an archive file. |
private TArchiveDetector |
detector
|
private TFile |
enclArchive
|
private FsEntryName |
enclEntryName
|
private TFile |
innerArchive
|
private static boolean |
lenient
|
private static Set<File> |
roots
The file system roots. |
private static long |
serialVersionUID
|
private static String |
UNC_PREFIX
The prefix of a UNC (a Windows concept). |
| Fields inherited from class java.io.File |
|---|
pathSeparator, pathSeparatorChar, separator, separatorChar |
| Constructor Summary | |
|---|---|
|
TFile(File file)
Copy constructor. |
|
TFile(File parent,
String member)
Equivalent to new TFile(parent, child, null). |
|
TFile(File parent,
String member,
TArchiveDetector detector)
Constructs a new TFile instance which uses the given
TArchiveDetector to detect any archive files in its path
and configure their parameters. |
|
TFile(File file,
TArchiveDetector detector)
Constructs a new TFile instance which may use the given
TArchiveDetector to detect any archive files in its path. |
private |
TFile(File delegate,
TFile innerArchive,
TArchiveDetector detector)
|
private |
TFile(FsMountPoint mountPoint,
TArchiveDetector detector)
|
|
TFile(FsPath path)
Constructs a new TFile instance from the given
path. |
private |
TFile(FsPath path,
TArchiveDetector detector)
|
|
TFile(String path)
Equivalent to new TFile(path, getDefaultArchiveDetector()). |
|
TFile(String parent,
String member)
Equivalent to new TFile(parent, child, getDefaultArchiveDetector()). |
|
TFile(String parent,
String member,
TArchiveDetector detector)
Constructs a new TFile instance which uses the given
TArchiveDetector to detect any archive files in its path. |
|
TFile(String path,
TArchiveDetector detector)
Constructs a new TFile instance which uses the given
TArchiveDetector to detect any archive files in its path. |
|
TFile(URI uri)
Constructs a new TFile instance from the given
uri. |
| Method Summary | |
|---|---|
boolean |
archiveCopyAllFrom(File src)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllFrom(File src,
TArchiveDetector detector)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllFrom(File src,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
Recursively copies the file or directory src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst,
TArchiveDetector detector)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyAllTo(File dst,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
Recursively copies this file or directory to the file or directory dst and tries to preserve all attributes of the source
file to the destination file, too. |
boolean |
archiveCopyFrom(File src)
Copies the file src to this file and tries to preserve
all attributes of the source file to the destination file, too. |
boolean |
archiveCopyTo(File dst)
Copies this file to the file dst and tries to preserve
all attributes of the source
file to the destination file, too. |
boolean |
canRead()
|
boolean |
canWrite()
|
static void |
cat(InputStream in,
OutputStream out)
Copies the data from the given input stream to the given output stream without closing them. |
boolean |
catFrom(InputStream in)
Copies the input stream in to this file or
entry in an archive file without closing the input stream. |
boolean |
catTo(OutputStream out)
Copies this file or entry in an archive file to the output stream out without closing it. |
int |
compareTo(File other)
The implementation in the class TFile delegates the call to its
decorated file. |
boolean |
contains(File file)
Returns true if and only if the path represented
by this instance contains the path represented by the specified
file,
where a path is said to contain another path if and only
if it is equal or a parent of the other path. |
static boolean |
contains(File a,
File b)
Returns true if and only if the path represented
by a contains the path represented by b,
where a path is said to contain another path if and only
if it is equal or a parent of the other path. |
private static TFile[] |
convert(File[] files,
TArchiveDetector detector)
|
boolean |
copyAllFrom(File src)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllFrom(File src,
TArchiveDetector detector)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllFrom(File src,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
Recursively copies the file or directory src
to this file or directory. |
boolean |
copyAllTo(File dst)
Recursively copies this file or directory to the file or directory dst. |
boolean |
copyAllTo(File dst,
TArchiveDetector detector)
Recursively copies this file or directory to the file or directory dst. |
boolean |
copyAllTo(File dst,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
Recursively copies this file or directory to the file or directory dst. |
boolean |
copyFrom(File src)
Copies the file src to this file. |
boolean |
copyFrom(InputStream in)
Copies the input stream in to this file and closes it. |
boolean |
copyTo(File dst)
Copies this file to the file dst. |
boolean |
copyTo(OutputStream out)
Copies this file to the output stream out and closes it. |
static void |
cp_p(File src,
File dst)
Copies src to dst and tries to preserve
all attributes of the source file to the destination file, too. |
static void |
cp(File src,
File dst)
Copies src to dst. |
static void |
cp(InputStream in,
OutputStream out)
Copies the data from the given input stream to the given output stream and always closes both streams - even if an exception occurs. |
boolean |
createNewFile()
Creates a new, empty file similar to its superclass implementation. |
private TFile[] |
delegateListFiles(FileFilter filter,
TArchiveDetector detector)
|
boolean |
delete()
Deletes an archive entry, archive file or regular node in the real file system. |
boolean |
deleteAll()
Deletes the entire directory tree represented by this object, regardless whether this is a file or directory, whether the directory is empty or not or whether the file or directory is actually an archive file, an entry in an archive file or not enclosed in an archive file at all. |
void |
deleteOnExit()
|
boolean |
equals(Object that)
The implementation in the class TFile delegates the call to its
decorated file. |
boolean |
exists()
This file system operation is virtually atomic. |
TFile |
getAbsoluteFile()
|
String |
getAbsolutePath()
|
TArchiveDetector |
getArchiveDetector()
Returns the TArchiveDetector that was used to construct this
object - never null. |
TFile |
getCanonicalFile()
|
String |
getCanonicalPath()
|
TFile |
getCanOrAbsFile()
This convenience method simply returns the canonical form of this abstract path or the normalized absolute form if resolving the prior fails. |
String |
getCanOrAbsPath()
This convenience method simply returns the canonical form of this abstract path or the normalized absolute form if resolving the prior fails. |
Icon |
getClosedIcon()
If this file is a true archive file, its archive driver is asked to return an icon to be displayed for this file. |
(package private) FsController<?> |
getController()
Returns a file system controller if and only if the path denotes an archive file, or null otherwise. |
static TArchiveDetector |
getDefaultArchiveDetector()
Returns the TArchiveDetector to use if no archive detector is
explicitly passed to the constructor of a TFile instance. |
TFile |
getEnclArchive()
Returns the enclosing archive file in this path. |
String |
getEnclEntryName()
Returns the entry path in the enclosing archive file. |
(package private) FsEntryName |
getEnclEntryName0()
|
File |
getFile()
Returns the decorated file object. |
TFile |
getInnerArchive()
Returns the innermost archive file in this path. |
String |
getInnerEntryName()
Returns the entry name in the innermost archive file. |
(package private) FsEntryName |
getInnerEntryName0()
|
String |
getName()
|
TFile |
getNonArchivedParentFile()
Returns the first parent directory (starting from this file) which is not an archive file or a file located in an archive file. |
TFile |
getNormalizedAbsoluteFile()
Similar to getAbsoluteFile(), but removes any
"." and ".." directories from the path name wherever
possible. |
String |
getNormalizedAbsolutePath()
Similar to getAbsolutePath(), but removes any redundant
"." and ".." directories from the path name. |
TFile |
getNormalizedFile()
Removes any "." and ".." directories from the path name
wherever possible. |
String |
getNormalizedPath()
Removes any redundant ".", ".." directories from the
path name. |
Icon |
getOpenIcon()
If this file is a true archive file, its archive driver is asked to return an icon to be displayed for this file. |
String |
getParent()
|
TFile |
getParentFile()
|
String |
getPath()
|
TFile |
getTopLevelArchive()
Returns The top level archive file in the path or null
if this path does not denote an archive. |
int |
hashCode()
The implementation in the class TFile delegates the call to its
decorated file. |
private boolean |
invariants()
Checks the invariants of this class and throws an AssertionError if any is violated even if assertion checking is disabled. |
boolean |
isAbsolute()
|
boolean |
isArchive()
Returns true if and only if the path represented by this
instance denotes an archive file. |
boolean |
isDirectory()
Similar to its super class implementation, but returns true for a valid archive file. |
boolean |
isEntry()
Returns true if and only if the path represented by this
instance names an archive file as an ancestor. |
boolean |
isFile()
Similar to its super class implementation, but returns false for a valid archive file. |
boolean |
isFileSystemRoot()
Returns true if and only if this file denotes a file system
root or a UNC (if running on the Windows platform). |
boolean |
isHidden()
|
static boolean |
isLenient()
Returns the value of the class property lenient. |
boolean |
isParentOf(File file)
Returns true if and only if the path represented
by this instance is a direct or indirect parent of the path
represented by the specified file. |
boolean |
isUNC()
Returns true if and only if this file denotes a UNC. |
private static boolean |
isUNC(String path)
Returns true iff the given path is a UNC. |
long |
lastModified()
Returns a long value representing the time this file was
last modified, measured in milliseconds since the epoch (00:00:00 GMT,
January 1, 1970), or 0L if the file does not exist or if an
I/O error occurs or if this is a ghost directory in an archive file. |
long |
length()
Returns the (uncompressed) getLength of the file. |
String[] |
list()
Returns the names of the members in this directory in a newly created array. |
String[] |
list(FilenameFilter filter)
Returns the names of the members in this directory which are accepted by filenameFilter in a newly created array. |
TFile[] |
listFiles()
Equivalent to listFiles((FilenameFilter) null, getArchiveDetector()). |
TFile[] |
listFiles(FileFilter fileFilter)
Equivalent to listFiles(fileFilter, getArchiveDetector()). |
TFile[] |
listFiles(FileFilter filter,
TArchiveDetector detector)
Returns TFile objects for the members in this directory
which are accepted by fileFilter in a newly created array. |
TFile[] |
listFiles(FilenameFilter filenameFilter)
Equivalent to listFiles(filenameFilter, getArchiveDetector()). |
TFile[] |
listFiles(FilenameFilter filter,
TArchiveDetector detector)
Returns TFile objects for the members in this directory
which are accepted by filenameFilter in a newly created
array. |
TFile[] |
listFiles(TArchiveDetector detector)
Returns TFile objects for the members in this directory
in a newly created array. |
boolean |
mkdir()
Creates a new, empty (virtual) directory similar to its superclass implementation. |
boolean |
mkdirs()
|
private void |
parse(FsPath path,
TArchiveDetector detector)
|
private void |
readObject(ObjectInputStream in)
|
boolean |
renameTo(File dst)
Equivalent to renameTo(dst, getArchiveDetector()). |
boolean |
renameTo(File dst,
TArchiveDetector detector)
Behaves similar to the super class, but renames this file or directory by recursively copying its data if this object or the dst
object is either an archive file or an entry located in an archive file. |
private void |
scan(TFile ancestor)
Initialize this file object by scanning its path for archive files, using the given ancestor file (i.e. a direct or
indirect parent file) if any. |
private void |
scan(TFile ancestor,
TArchiveDetector detector,
int skip,
String path,
StringBuilder enclEntryNameBuf,
Paths.Splitter splitter)
|
static void |
setDefaultArchiveDetector(TArchiveDetector detector)
Sets the TArchiveDetector to use if no archive detector is
explicitly passed to the constructor of a TFile instance. |
boolean |
setLastModified(long time)
Sets the last modification of this file or (virtual) directory. |
static void |
setLenient(boolean lenient)
Sets the value of the class property lenient. |
boolean |
setReadOnly()
Like the super class implementation, but is aware of archive files in its path. |
static void |
sync(BitField<FsSyncOption> options)
Commits all unsynchronized changes to the contents of all federated file systems (i.e. archive files) to their respective parent file system. |
static void |
sync(TFile archive,
BitField<FsSyncOption> options)
Similar to sync(options),
but synchronizes only the given archive and all its member file
systems. |
FsPath |
toFsPath()
|
String |
toString()
|
URI |
toURI()
|
URL |
toURL()
Deprecated. |
static void |
umount()
Equivalent to sync(FsController.UMOUNT). |
static void |
umount(boolean closeStreams)
Equivalent to sync( BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeStreams))
. |
static void |
umount(boolean waitForInputStreams,
boolean closeInputStreams,
boolean waitForOutputStreams,
boolean closeOutputStreams)
Equivalent to sync( BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.WAIT_CLOSE_INPUT, waitForInputStreams)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeInputStreams)
.set(FsSyncOption.WAIT_CLOSE_OUTPUT, waitForOutputStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeOutputStreams))
. |
static void |
umount(TFile archive)
Equivalent to sync(archive, BitField.of(FsController.UMOUNT))
. |
static void |
umount(TFile archive,
boolean closeStreams)
Equivalent to sync( archive,
BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeStreams))
. |
static void |
umount(TFile archive,
boolean waitForInputStreams,
boolean closeInputStreams,
boolean waitForOutputStreams,
boolean closeOutputStreams)
Equivalent to sync( archive,
BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.WAIT_CLOSE_INPUT, waitForInputStreams)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeInputStreams)
.set(FsSyncOption.WAIT_CLOSE_OUTPUT, waitForOutputStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeOutputStreams))
. |
private void |
writeObject(ObjectOutputStream out)
|
private Object |
writeReplace()
|
| Methods inherited from class java.io.File |
|---|
canExecute, createTempFile, createTempFile, getFreeSpace, getTotalSpace, getUsableSpace, listRoots, setExecutable, setExecutable, setReadable, setReadable, setWritable, setWritable |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static final long serialVersionUID
private static final Set<File> roots
private static boolean lenient
private static TArchiveDetector defaultDetector
private transient File delegate
File
instance, then this field is initialized with that instance.
This enables federation of file system implementations and is essential
to enable the broken implementation in
JFileChooser to browse archive files.
private transient TArchiveDetector detector
@Nullable private transient TFile innerArchive
@Nullable private transient TFile enclArchive
@Nullable private transient FsEntryName enclEntryName
@Nullable private transient volatile FsController<?> controller
null.
This field should be considered to be final!
readObject(java.io.ObjectInputStream)private static final String UNC_PREFIX
| Constructor Detail |
|---|
public TFile(File file)
new TFile(template, getDefaultArchiveDetector()).
public TFile(File file,
@CheckForNull
TArchiveDetector detector)
TFile instance which may use the given
TArchiveDetector to detect any archive files in its path.
file - The file to decorate. If this is an instance
of this class, its fields are copied and the
detector parameter is not used to scan the path.detector - The object to use for the detection of any archive files
in the path if necessary.
This parameter is ignored if and only if file is an
instance of this class.
Otherwise, if it's null, the
default archive detector is
used.public TFile(String path)
new TFile(path, getDefaultArchiveDetector()).
public TFile(String path,
@CheckForNull
TArchiveDetector detector)
TFile instance which uses the given
TArchiveDetector to detect any archive files in its path.
path - The path of the file.detector - The object to use for the detection of any archive files
in the path.
If this is null, the
default archive detector is
used.
public TFile(String parent,
String member)
new TFile(parent, child, getDefaultArchiveDetector()).
public TFile(String parent,
String member,
@CheckForNull
TArchiveDetector detector)
TFile instance which uses the given
TArchiveDetector to detect any archive files in its path.
parent - The parent path as a String.member - The child path as a String.detector - The object to use for the detection of any archive files
in the path.
If this is null, the
default archive detector is
used.
public TFile(File parent,
String member)
new TFile(parent, child, null).
parent - The parent directory as a TFile instance.
If this parameter is an instance of this class, its
TArchiveDetector is used to detect any archive files
in the path of this TFile instance.
Otherwise, the getDefaultArchiveDetector() is used.
This is used in order to make this TFile instance
behave as if it had been created by one of the listFiles()
methods called on parent instead.member - The child path as a String.
public TFile(File parent,
String member,
@CheckForNull
TArchiveDetector detector)
TFile instance which uses the given
TArchiveDetector to detect any archive files in its path
and configure their parameters.
parent - The parent directory as a TFile instance.member - The child path as a String.detector - The object to use for the detection of any archive files
in the path.
If this is null and parent is an
instance of this class, the archive detector is copied from
parent.
If this is null and parent is
not an instance of this class, the
default archive detector
is used.public TFile(URI uri)
TFile instance from the given
uri.
This method behaves similar to the super class constructor
File.File(URI) with the following amendment:
If the URI matches the pattern scheme:file:path!/entry,
then the constructed file object treats the URI like an entry in the
federated file system of the type named scheme.
This may be applied unlimitedly recursively to access archive entries
within other archive files.
Note that the newly created TFile instance uses the
default archive detector to look
up archive drivers for the named scheme(s).
uri - an absolute URI with a scheme supported by the
default archive detector.
IllegalArgumentException - if the given URI does not conform to
the syntax constraints for FsPaths.public TFile(FsPath path)
TFile instance from the given
path.
This method behaves similar to the super class constructor
File.File(URI) with the following amendment:
If the path matches the pattern scheme:file:path!/entry,
then the constructed file object treats the URI like an entry in the
federated file system of the type named scheme.
This may be applied unlimitedly recursively to access archive entries
within other archive files.
Note that the newly created TFile instance uses the
default archive detector to look
up archive drivers for the named scheme(s).
path - an absolute path with a scheme supported by the
default archive detector.
IllegalArgumentException - if the given URI does not conform to
the syntax constraints for FsPaths.
private TFile(FsPath path,
TArchiveDetector detector)
private TFile(FsMountPoint mountPoint,
TArchiveDetector detector)
private TFile(File delegate,
@CheckForNull
TFile innerArchive,
TArchiveDetector detector)
| Method Detail |
|---|
private void parse(FsPath path,
TArchiveDetector detector)
private void scan(@CheckForNull
TFile ancestor)
ancestor file (i.e. a direct or
indirect parent file) if any.
delegate and detector must already be initialized!
Must not be called to re-initialize this object!
private void scan(@CheckForNull
TFile ancestor,
TArchiveDetector detector,
int skip,
String path,
StringBuilder enclEntryNameBuf,
Paths.Splitter splitter)
private Object writeReplace()
throws ObjectStreamException
ObjectStreamException
private void writeObject(ObjectOutputStream out)
throws IOException
IOException
private void readObject(ObjectInputStream in)
throws IOException,
ClassNotFoundException
IOException
ClassNotFoundExceptionprivate boolean invariants()
The constructors call this method like this:
assert invariants();
This calls the method if and only if assertions are enabled in order
to assert that the instance invariants are properly obeyed.
If assertions are disabled, the call to this method is thrown away by
the HotSpot compiler, so there is no performance penalty.
When deserializing however, this method is called regardless of the
assertion status. On error, the AssertionError is wrapped
in an InvalidObjectException and thrown instead.
true
AssertionError - If any invariant is violated even if assertions
are disabled.
public static void sync(BitField<FsSyncOption> options)
throws FsSyncException
FsSyncWarningException - if only warning conditions
occur.
This implies that the respective parent file system has been
updated with constraints, such as a failure to set the last
modification time of the entry for the federated file system
(i.e. archive file) in its parent file system.
FsSyncException - if any error conditions occur.
This implies loss of data!
IllegalArgumentException - if the combination of options is
illegal.
public static void sync(TFile archive,
BitField<FsSyncOption> options)
throws FsSyncException
sync(options),
but synchronizes only the given archive and all its member file
systems.
If a client application needs to sync an individual federated file system, the following idiom can be used:
if (file.isArchive() && file.getEnclArchive() == null) // filter top level federated file system
if (file.isDirectory()) // ignore false positives
TFile.sync(file); // sync federated file system and all its members
Again, this will also sync all federated file systems which are
located within the file system referred to by file.
archive - a top level federated file system.
IllegalArgumentException - If archive is not a top level
federated file system or the combination of options is illegal.
FsSyncExceptionsync(BitField)
public static void umount()
throws FsSyncException
sync(FsController.UMOUNT).
FsSyncExceptionsync(BitField)
public static void umount(boolean closeStreams)
throws FsSyncException
sync( BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeStreams))
.
FsSyncExceptionsync(BitField)
public static void umount(boolean waitForInputStreams,
boolean closeInputStreams,
boolean waitForOutputStreams,
boolean closeOutputStreams)
throws FsSyncException
sync( BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.WAIT_CLOSE_INPUT, waitForInputStreams)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeInputStreams)
.set(FsSyncOption.WAIT_CLOSE_OUTPUT, waitForOutputStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeOutputStreams))
.
FsSyncExceptionsync(BitField)
public static void umount(TFile archive)
throws FsSyncException
sync(archive, BitField.of(FsController.UMOUNT))
.
FsSyncExceptionsync(TFile, BitField)
public static void umount(TFile archive,
boolean closeStreams)
throws FsSyncException
sync( archive,
BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeStreams))
.
FsSyncExceptionsync(TFile, BitField)
public static void umount(TFile archive,
boolean waitForInputStreams,
boolean closeInputStreams,
boolean waitForOutputStreams,
boolean closeOutputStreams)
throws FsSyncException
sync( archive,
BitField.of(FsSyncOption.CLEAR_CACHE)
.set(FsSyncOption.WAIT_CLOSE_INPUT, waitForInputStreams)
.set(FsSyncOption.FORCE_CLOSE_INPUT, closeInputStreams)
.set(FsSyncOption.WAIT_CLOSE_OUTPUT, waitForOutputStreams)
.set(FsSyncOption.FORCE_CLOSE_OUTPUT, closeOutputStreams))
.
FsSyncExceptionsync(TFile, BitField)public static boolean isLenient()
lenient.
By default, the value of this class property is true.
setLenient(boolean)public static void setLenient(boolean lenient)
lenient.
This class property controls whether archive files and their member
directories get created on the fly if they don't exist.
By default, the value of this class property is true.
Consider the following path: a/outer.zip/b/inner.zip/c.
Now let's assume that a exists as a plain old directory in the
OS' file system, while all other parts of this path don't, and that the
TrueZIP Driver ZIP module is present on the run-time class path in order
to recognize outer.zip and inner.zip as ZIP files by
default.
Now, if this class property is set to false, then an application
would have to call new TFile("a/outer.zip/b/inner.zip").mkdirs()
before it could actually create the innermost c entry as a file
or directory.
More formally, before an application could access an entry in a federated file system, all its parent directories would need to exist, including archive files. This emulates the behaviour of native file systems.
If this class property is set to true however, then any missing
parent directories (including archive files) up to the outermost archive
file outer.zip would get created on the fly when using
operations to create the innermost element of the path c.
This allows applications to succeed with doing this:
new TFile("a/outer.zip/b/inner.zip/c").createNewFile(),
or that:
new TFileOutputStream("a/outer.zip/b/inner.zip/c").
Note that in either case the parent directory of the outermost archive
file a must exist - TrueZIP does not create directories in the
OS file system on the fly!
isLenient()public static TArchiveDetector getDefaultArchiveDetector()
TArchiveDetector to use if no archive detector is
explicitly passed to the constructor of a TFile instance.
This class property is initially set to
TDefaultArchiveDetector.ALL
setDefaultArchiveDetector(de.schlichtherle.truezip.file.TArchiveDetector)public static void setDefaultArchiveDetector(TArchiveDetector detector)
TArchiveDetector to use if no archive detector is
explicitly passed to the constructor of a TFile instance.
When a new TFile instance is constructed, but no archive
detector parameter is provided, then the value of this class property
is used.
So changing the value of this class property affects only subsequently
constructed TFile instances - not any existing ones.
detector - the TArchiveDetector to use for subsequently
constructed TFile instances if no archive detector is
explicitly passed to the constructorgetDefaultArchiveDetector()@Nullable public TFile getNonArchivedParentFile()
@Nullable public String getParent()
getParent in class File@Nullable public TFile getParentFile()
getParentFile in class Filepublic TFile getAbsoluteFile()
getAbsoluteFile in class Filepublic String getAbsolutePath()
getAbsolutePath in class Filepublic TFile getNormalizedAbsoluteFile()
getAbsoluteFile(), but removes any
"." and ".." directories from the path name wherever
possible.
The result is similar to getCanonicalFile(), but symbolic
links are not resolved.
This may be useful if getCanonicalFile() throws an
IOException.
getCanonicalFile(),
getNormalizedFile()public String getNormalizedAbsolutePath()
getAbsolutePath(), but removes any redundant
"." and ".." directories from the path name.
The result is similar to getCanonicalPath(), but symbolic
links are not resolved.
This may be useful if getCanonicalPath() throws an
IOException.
getCanonicalPath(),
getNormalizedPath()public TFile getNormalizedFile()
"." and ".." directories from the path name
wherever possible.
public String getNormalizedPath()
".", ".." directories from the
path name.
String.
public TFile getCanonicalFile()
throws IOException
getCanonicalFile in class FileIOException
public String getCanonicalPath()
throws IOException
getCanonicalPath in class FileIOExceptionpublic final TFile getCanOrAbsFile()
public String getCanOrAbsPath()
String instance.public boolean isArchive()
true if and only if the path represented by this
instance denotes an archive file.
Whether or not this is true solely depends on the
TArchiveDetector which was used to construct this TFile
instance.
Please note that no file system tests are performed!
If a client application needs to know whether this file really isExisting
as an archive file in the file system (and the correct password has
been entered in case it's a RAES encrypted ZIP file), it should
subsequently call isDirectory(), too.
This will automount the (virtual) file system from the archive file and
return true if and only if it's a valid archive file.
isDirectory(),
isEntry()public boolean isEntry()
true if and only if the path represented by this
instance names an archive file as an ancestor.
Whether or not this is true solely depends on the
TArchiveDetector which was used to construct this TFile
instance.
Please note that no tests on the file's true state are performed!
If you need to know whether this file is really an entry in an archive
file (and the correct password has been entered in case it's a RAES
encrypted ZIP file), you should call
getParentFile().isDirectory(), too.
This will automount the (virtual) file system from the archive file and
return true if and only if it's a valid archive file.
isArchive()@CheckForNull public TFile getInnerArchive()
null otherwise.
This method always returns a normalized path, i.e. all occurences of
"." and ".." in the path name are removed according to
their meaning wherever possible.
In order to support unlimited nesting levels, this method returns
a TFile instance which again could be an entry within
another archive file.
@Nullable public String getInnerEntryName()
"".
If this object is a file or directory located within an
archive file, then this method returns the relative path of
the entry in the enclosing archive file separated by the entry
separator character '/', or null
otherwise.
This method always returns an undotified path, i.e. all occurences of
"." and ".." in the path name are removed according to
their meaning wherever possible.
@Nullable FsEntryName getInnerEntryName0()
@CheckForNull public TFile getEnclArchive()
null otherwise.
This method always returns a normalized path, i.e. all occurences of
"." and ".." in the path name are removed according to
their meaning wherever possible.
In order to support unlimited nesting levels, this method returns
a TFile instance which again could be an entry within
another archive file.
@Nullable public String getEnclEntryName()
'/', or null otherwise.
This method always returns an undotified path, i.e. all occurences of
"." and ".." in the path are removed according to their
meaning wherever possible.
@Nullable final FsEntryName getEnclEntryName0()
public final TArchiveDetector getArchiveDetector()
TArchiveDetector that was used to construct this
object - never null.
public File getFile()
If this file instance has been created from a FileSystemView,
the decorated file object may be an instance of a sibling class, i.e.
another sub-class of File.
File class or any of its
sub-classes, but never an instance of this class and never
null.@Nullable FsController<?> getController()
null otherwise.
public boolean isParentOf(File file)
true if and only if the path represented
by this instance is a direct or indirect parent of the path
represented by the specified file.
Note:
file - The path to test for being a child of this path.
NullPointerException - If the parameter is null.public boolean contains(File file)
true if and only if the path represented
by this instance contains the path represented by the specified
file,
where a path is said to contain another path if and only
if it is equal or a parent of the other path.
Note:
file - The path to test for being contained by this path.
NullPointerException - If the parameter is null.
public static boolean contains(File a,
File b)
true if and only if the path represented
by a contains the path represented by b,
where a path is said to contain another path if and only
if it is equal or a parent of the other path.
Note:
a - The file to test for containing b.b - The file to test for being contained by a.
NullPointerException - If any parameter is null.public boolean isFileSystemRoot()
true if and only if this file denotes a file system
root or a UNC (if running on the Windows platform).
public boolean isUNC()
true if and only if this file denotes a UNC.
Note that this should be relevant on the Windows platform only.
private static boolean isUNC(String path)
true iff the given path is a UNC.
Note that this may be only relevant on the Windows platform.
public int hashCode()
The implementation in the class TFile delegates the call to its
decorated file.
hashCode in class Fileequals(Object)public boolean equals(Object that)
The implementation in the class TFile delegates the call to its
decorated file.
This implies that only the hierarchicalized file system path
of this file instance is considered in the comparison.
E.g. new TFile(FsPath.create("zip:file:/archive!/entry")) and
new TFile(FsPath.create("tar:file:/archive!/entry")) would
compare equal because their hierarchicalized file system path is
"file:/archive/entry".
More formally, let a and b be two TFile objects.
Then if the expression
a.toFsPath().hierarchicalize().equals(b.toFsPath().hierarchicalize())
is true, the expression a.equals(b) is also true.
Note that this does not work vice versa:
E.g. on Windows, the expression
new TFile("file").equals(new TFile("FILE")) is true, but
new TFile("file").toFsPath().hierarchicalize().equals(new TFile("FILE").toFsPath().hierarchicalize())
is false because FsPath.equals(Object) is case sensitive.
equals in class FilehashCode(),
compareTo(File)public int compareTo(File other)
The implementation in the class TFile delegates the call to its
decorated file.
This implies that only the hierarchicalized file system path
Note that this implies that only the hierarchicalized file system path
of this file instance is considered in the comparison.
E.g. new TFile(FsPath.create("zip:file:/archive!/entry")) and
new TFile(FsPath.create("tar:file:/archive!/entry")) would
compare equal because their hierarchicalized file system path is
"file:/archive/entry".
More formally, let a and b be two TFile objects.
Then if the expression
a.toFsPath().hierarchicalize().compareTo(b.toFsPath().hierarchicalize()) == 0
is true, the expression a.compareTo(b) == 0 is also true.
Note that this does not work vice versa:
E.g. on Windows, the expression
new TFile("file").compareTo(new TFile("FILE")) == 0 is true, but
new TFile("file").toFsPath().hierarchicalize().compareTo(new TFile("FILE").toFsPath().hierarchicalize()) == 0
is false because FsPath.equals(Object) is case sensitive.
compareTo in interface Comparable<File>compareTo in class Fileequals(Object)public TFile getTopLevelArchive()
null
if this path does not denote an archive.
A top level archive is not enclosed in another archive.
If this does not return null, this denotes the longest
part of the path which actually may (but does not need to) exist
as a regular file in the real file system.
public String getPath()
getPath in class Filepublic String getName()
getName in class Filepublic boolean isAbsolute()
isAbsolute in class Filepublic boolean isHidden()
isHidden in class Filepublic String toString()
toString in class Filepublic FsPath toFsPath()
public URI toURI()
toURI in class File
@Deprecated
public URL toURL()
throws MalformedURLException
toURL in class FileMalformedURLExceptionpublic boolean exists()
exists in class Filepublic boolean isFile()
false for a valid archive file.
This file system operation is virtually atomic.
isFile in class Filepublic boolean isDirectory()
true for a valid archive file.
In case a RAES encrypted ZIP file is tested which is accessed for the
first time, the user is prompted for the password (if password based
encryption is used).
Note that this is not the only method which would prompt the user for
a password: For example, length() would prompt the user and
return 0 unless the user cancels the prompting or the
file is a false positive archive file.
This file system operation is virtually atomic.
isDirectory in class File@CheckForNull public Icon getOpenIcon()
@CheckForNull public Icon getClosedIcon()
public boolean canRead()
canRead in class Filepublic boolean canWrite()
canWrite in class Filepublic boolean setReadOnly()
true if the entry isExisting and the
archive file was mounted read only.
This file system operation is virtually atomic.
setReadOnly in class Filepublic long length()
0 in order
to correctly emulate virtual directories across all platforms.
In case a RAES encrypted ZIP file is tested which is accessed for the
first time, the user is prompted for the password (if password based
encryption is used).
Note that this is not the only method which would prompt the user for
a password: For example, isDirectory() would prompt the user and
return true unless the user cancels the prompting or the
file is a false positive archive file.
This file system operation is virtually atomic.
length in class Filepublic long lastModified()
long value representing the time this file was
last modified, measured in milliseconds since the epoch (00:00:00 GMT,
January 1, 1970), or 0L if the file does not exist or if an
I/O error occurs or if this is a ghost directory in an archive file.
This file system operation is virtually atomic.
lastModified in class Filepublic boolean setLastModified(long time)
Note that calling this method may incur a severe performance penalty
if the file is an entry in an archive file which has just been written
(such as after a normal copy operation).
If you want to copy a file's contents as well as its last modification
time, use archiveCopyFrom(File) or
archiveCopyTo(File) instead.
This file system operation is virtually atomic.
setLastModified in class FilearchiveCopyFrom(File),
archiveCopyTo(File),
Package description for more information
about ghost directories@Nullable public String[] list()
Note: Archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
list in class File
@Nullable
public String[] list(@CheckForNull
FilenameFilter filter)
filenameFilter in a newly created array.
The returned array is not sorted.
Note: Archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
list in class Filenull if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.@Nullable public TFile[] listFiles()
listFiles((FilenameFilter) null, getArchiveDetector()).
listFiles in class File@Nullable public TFile[] listFiles(TArchiveDetector detector)
TFile objects for the members in this directory
in a newly created array.
The returned array is not sorted.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
detector - The archive detector to detect any archives files in
the member file names.
null if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.
@Nullable
public TFile[] listFiles(@CheckForNull
FilenameFilter filenameFilter)
listFiles(filenameFilter, getArchiveDetector()).
listFiles in class File
@Nullable
public TFile[] listFiles(@CheckForNull
FilenameFilter filter,
TArchiveDetector detector)
TFile objects for the members in this directory
which are accepted by filenameFilter in a newly created
array.
The returned array is not sorted.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
detector - The archive detector to detect any archives files in
the member file names.
null if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.
@Nullable
private static TFile[] convert(File[] files,
TArchiveDetector detector)
@Nullable
public TFile[] listFiles(@CheckForNull
FileFilter fileFilter)
listFiles(fileFilter, getArchiveDetector()).
listFiles in class File
@Nullable
public TFile[] listFiles(@CheckForNull
FileFilter filter,
TArchiveDetector detector)
TFile objects for the members in this directory
which are accepted by fileFilter in a newly created array.
The returned array is not sorted.
Note that archive entries with absolute paths are ignored by this method and are never returned.
This file system operation is virtually atomic.
detector - The archive detector to detect any archives files in
the member file names.
null if this is not a directory or an archive file,
a valid (but maybe empty) array otherwise.
@Nullable
private TFile[] delegateListFiles(@CheckForNull
FileFilter filter,
TArchiveDetector detector)
public boolean createNewFile()
throws IOException
This file system operation is virtually atomic.
createNewFile in class FileIOExceptionmkdir()public boolean mkdirs()
mkdirs in class Filepublic boolean mkdir()
isArchive() returns
true.
Example:
new TFile("archive.zip").mkdir();
Alternatively, archive files can be created on the fly by simply
creating their entries.
Example:
new TFileOutputStream("archive.zip/README");
These examples assume TrueZIP's default configuration where ZIP file
recognition is enabled and isLenient() returns true.
This file system operation is virtually atomic.
mkdir in class Filepublic boolean delete()
This file system operation is virtually atomic.
delete in class FiledeleteAll()public boolean deleteAll()
This file system operation is not atomic.
public void deleteOnExit()
deleteOnExit in class Filepublic final boolean renameTo(File dst)
renameTo(dst, getArchiveDetector()).
renameTo in class File
public boolean renameTo(File dst,
TArchiveDetector detector)
dst
object is either an archive file or an entry located in an archive file.
Hence, in these cases only this file system operation is not
atomic.
detector - The object used to detect any archive
files in the path and configure their parameters.public boolean copyFrom(InputStream in)
in to this file and closes it.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | Always |
| Direct Data Copying (DDC) | No |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.public boolean copyFrom(File src)
src to this file.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.public boolean copyAllFrom(File src)
src
to this file or directory.
This version uses the TArchiveDetector which was used to
construct this object to detect any archive files in the source
and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.
public boolean copyAllFrom(File src,
TArchiveDetector detector)
src
to this file or directory.
This version uses the given archive detector to detect any archive
files in the source and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.detector - The object used to detect any archive files
in the source and destination directory trees.
public boolean copyAllFrom(File src,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
src
to this file or directory.
By using different TArchiveDetectors for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector could be
TDefaultArchiveDetector.ALL and dstDetector must be
TDefaultArchiveDetector.NULL) or changing the charset by configuring
a custom TDefaultArchiveDetector.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.srcDetector - The object used to detect any archive files
in the source directory tree.dstDetector - The object used to detect any archive files
in the destination directory tree.
true if and only if the operation succeeded.public boolean copyTo(OutputStream out)
out and closes it.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | Always |
| Direct Data Copying (DDC) | No |
| Deletes partial written files on failure | n/a |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.public boolean copyTo(File dst)
dst.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
true if the file has been successfully copied.
NullPointerException - If any parameter is null.public boolean copyAllTo(File dst)
dst.
This version uses the TArchiveDetector which was used to
construct this object to detect any archive files in the source
and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.
public boolean copyAllTo(File dst,
TArchiveDetector detector)
dst.
This version uses the given archive detector to detect any archive
files in the source and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.detector - The object used to detect any archive files
in the source and destination directory trees.
true if and only if the operation succeeded.
public boolean copyAllTo(File dst,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
dst.
By using different TArchiveDetectors for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector could be
TDefaultArchiveDetector.ALL and dstDetector must be
TDefaultArchiveDetector.NULL) or changing the charset by configuring
a custom TDefaultArchiveDetector.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.srcDetector - The object used to detect any archive files
in the source directory tree.dstDetector - The object used to detect any archive files
in the destination directory tree.
true if and only if the operation succeeded.public boolean archiveCopyFrom(File src)
src to this file and tries to preserve
all attributes of the source file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
true if and only if the operation succeeded.public boolean archiveCopyAllFrom(File src)
src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the TArchiveDetector which was used to
construct this object to detect any archive files in the source
and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.
public boolean archiveCopyAllFrom(File src,
TArchiveDetector detector)
src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the given archive detector to detect any archive files in the source and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.detector - The object used to detect any archive files
in the source and destination directory trees.
true if and only if the operation succeeded.
public boolean archiveCopyAllFrom(File src,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
src to this file
or directory and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
By using different TArchiveDetectors for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector could be
TDefaultArchiveDetector.ALL and dstDetector must be
TDefaultArchiveDetector.NULL) or changing the charset by configuring
a custom TDefaultArchiveDetector.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.srcDetector - The object used to detect any archive files
in the source directory tree.dstDetector - The object used to detect archive files
in the destination directory tree.
true if and only if the operation succeeded.public boolean archiveCopyTo(File dst)
dst and tries to preserve
all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.public boolean archiveCopyAllTo(File dst)
dst and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the TArchiveDetector which was used to
construct this object to detect any archive files in the
source and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.
true if and only if the operation succeeded.
NullPointerException - If any parameter is null.
public boolean archiveCopyAllTo(File dst,
TArchiveDetector detector)
dst and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
This version uses the given archive detector to detect any archive files in the source and destination directory trees. This version uses the given archive detector to detect any archive files in the source and destination directory trees.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.detector - The object used to detect any archive files
in the source and destination directory trees.
true if and only if the operation succeeded.
public boolean archiveCopyAllTo(File dst,
TArchiveDetector srcDetector,
TArchiveDetector dstDetector)
dst and tries to preserve all attributes of the source
file to the destination file, too.
Note that the current implementation only preserves the last
modification time.
By using different TArchiveDetectors for the source and
destination, this method can be used to do advanced stuff like
unzipping any archive file in the source tree to a plain directory
in the destination tree (where srcDetector could be
TDefaultArchiveDetector.ALL and dstDetector must be
TDefaultArchiveDetector.NULL) or changing the charset by configuring
a custom TDefaultArchiveDetector.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | Yes |
| Reads and overwrites special files | No |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | No |
| Atomic | No |
dst - The destination file. Note that although this just needs to
be a plain File, archive files and entries
are only supported for instances of this class.srcDetector - The object used to detect any archive files
in the source directory tree.dstDetector - The object used to detect any archive files
in the destination directory tree.
true if and only if the operation succeeded.
public static void cp(InputStream in,
OutputStream out)
throws IOException
This is a high performance implementation which uses a pooled background thread to fill a FIFO of data buffers which is concurrently flushed by the current thread.
| Feature | Supported |
|---|---|
| Preserves file attributes | n/a |
| Copies directories recursively | n/a |
| Reads and overwrites special files | n/a |
| Closes parameter streams | Always |
| Direct Data Copying (DDC) | n/a |
| Deletes partial written files on failure | n/a |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
in - the input stream.out - the output stream.
InputException - if copying the data fails because of an
IOException in the input stream.
IOException - if copying the data fails because of an
IOException in the output stream.cat(InputStream, OutputStream),
Copy Methods
public static void cp(File src,
File dst)
throws IOException
src to dst.
| Feature | Supported |
|---|---|
| Preserves file attributes | None |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.dst - The destination file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
IOException - If copying the data fails for some reason.
NullPointerException - If any parameter is null.
public static void cp_p(File src,
File dst)
throws IOException
src to dst and tries to preserve
all attributes of the source file to the destination file, too.
Currently, only the last modification time is preserved.
| Feature | Supported |
|---|---|
| Preserves file attributes | Best effort |
| Copies directories recursively | No |
| Reads and overwrites special files | Yes |
| Closes parameter streams | n/a |
| Direct Data Copying (DDC) | Yes |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
src - The source file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.dst - The destination file. Note that although this just needs to
be a plain File, archive entries are only
supported for instances of this class.
IOException - If copying the data fails for some reason.
NullPointerException - If any parameter is null.public boolean catFrom(InputStream in)
in to this file or
entry in an archive file without closing the input stream.
| Feature | Supported |
|---|---|
| Preserves file attributes | n/a |
| Copies directories recursively | n/a |
| Reads and overwrites special files | Yes |
| Closes parameter streams | Never |
| Direct Data Copying (DDC) | n/a |
| Deletes partial written files on failure | Yes |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
in - The input stream.
true if and only if the operation succeeded.public boolean catTo(OutputStream out)
out without closing it.
| Feature | Supported |
|---|---|
| Preserves file attributes | n/a |
| Copies directories recursively | n/a |
| Reads and overwrites special files | Yes |
| Closes parameter streams | Never |
| Direct Data Copying (DDC) | n/a |
| Deletes partial written files on failure | n/a |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
out - The output stream.
true if and only if the operation succeeded.
public static void cat(InputStream in,
OutputStream out)
throws IOException
cat because you could use it to concatenate the contents
of multiple streams.
This is a high performance implementation which uses a pooled background thread to fill a FIFO of data buffers which is concurrently flushed by the current thread.
| Feature | Supported |
|---|---|
| Preserves file attributes | n/a |
| Copies directories recursively | n/a |
| Reads and overwrites special files | n/a |
| Closes parameter streams | Never |
| Direct Data Copying (DDC) | n/a |
| Deletes partial written files on failure | n/a |
| Deletes partial written directories on failure | n/a |
| Atomic | No |
in - the input stream.out - the output stream.
InputException - if copying the data fails because of an
IOException in the input stream.
IOException - if copying the data fails because of an
IOException in the output stream.cp(InputStream, OutputStream),
Copy Methods
|
TrueZIP File* 7.0-rc1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||