|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.schlichtherle.io.Files
final class Files
Provides static utility methods for Files.
Note that in contrast to the File class, the methods in this
class accept and return plain java.io.File instances.
Full advantage is taken if a parameter is actually an instance of the
File class in this package, however.
TODO: Consider making this class public in TrueZIP 7 and remove the
stub methods for the same purpose in File.
| Nested Class Summary | |
|---|---|
private static class |
Files.CopyLock
A lock used when copying data from one archive to another. |
| Field Summary | |
|---|---|
private static Files.CopyLock |
copyLock
A lock used when copying data from one archive file to another. |
| Constructor Summary | |
|---|---|
protected |
Files()
This class cannot get instantiated. |
| Method Summary | |
|---|---|
static boolean |
contains(File a,
File b)
|
(package private) static boolean |
contains(String pathA,
String pathB)
Returns true if and only if the pathA contains
pathB. |
static void |
cp_r(boolean preserve,
File src,
File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
The name of this method is inspired by the Unix command line utility cp with the -r option to operate recursively. |
private static void |
cp_r0(boolean preserve,
File src,
File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
Unchecked parameters version. |
static void |
cp(boolean preserve,
File src,
File dst)
The name of this method is inspired by the Unix command line utility cp. |
static void |
cp(InputStream in,
OutputStream out)
|
private static void |
cp0(boolean preserve,
ArchiveController srcController,
String srcEntryName,
ArchiveController dstController,
String dstEntryName)
Copies a source file to a destination file, optionally preserving the source's last modification time. |
private static void |
cp0(boolean preserve,
ArchiveController srcController,
String srcEntryName,
File dst)
Copies a source file to a destination file, optionally preserving the source's last modification time. |
private static void |
cp0(boolean preserve,
File src,
File dst)
Unchecked parameters version. |
(package private) static void |
cp0(boolean preserve,
File src,
InputStream in,
ArchiveController dstController,
String dstEntryName)
Copies a source file to a destination file, optionally preserving the source's last modification time. |
private static void |
cp0(boolean preserve,
File src,
InputStream in,
File dst)
Copies a source file to a destination file, optionally preserving the source's last modification time. |
static File |
getCanOrAbsFile(File file)
Returns the canonical path of the given file or the normalized absolute path if canonicalizing the path fails due to an IOException. |
private static File |
getCanOrAbsFile0(File file)
|
static boolean |
isWritableOrCreatable(File file)
Returns true if the given file exists or can be created
and at least one byte can be successfully written to it - the file is
restored to its previous state afterwards. |
static boolean |
mv(File src,
File dst,
ArchiveDetector detector)
Moves the source to the destination by recursively copying and deleting its files and directories. |
private static boolean |
mv0(File src,
File dst,
ArchiveDetector detector)
|
static File |
normalize(File file)
Removes any "." and ".." |
static boolean |
rm_r(File file)
Removes the entire directory tree represented by the parameter, regardless whether it's 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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final Files.CopyLock copyLock
| Constructor Detail |
|---|
protected Files()
| Method Detail |
|---|
public static boolean contains(File a,
File b)
File.contains(java.io.File)
static boolean contains(String pathA,
String pathB)
pathA contains
pathB.
pathA - A valid file path.pathB - A valid file path.
NullPointerException - If any parameter is null.public static File getCanOrAbsFile(File file)
IOException.
java.io.File instance.
NullPointerException - If file is null.private static File getCanOrAbsFile0(File file)
public static File normalize(File file)
"." and ".."
directories from the path wherever possible.
file - The file instance which's path is to be normalized.
file if it was already in normalized form.
Otherwise, an object which's runtime class is guaranteed to
be java.io.File.public static boolean isWritableOrCreatable(File file)
true if the given file exists or can be created
and at least one byte can be successfully written to it - the file is
restored to its previous state afterwards.
This is a much stronger test than File.canWrite().
public static final boolean mv(File src,
File dst,
ArchiveDetector detector)
The name of this method is inspired by the Unix command line utility
mv although in most cases it performs a plain rename
operation rather than a copy-and-delete operation.
src - The source file or directory.
This must exist.dst - The destination file or directory.
This may or may not exist.
If it does, its contents are overwritten.detector - The object used to detect any archive
files in the path and configure their parameters.
File.renameTo(java.io.File, ArchiveDetector),
Third Party
Access using different Archive Detectors
private static boolean mv0(File src,
File dst,
ArchiveDetector detector)
public static final void cp_r(boolean preserve,
File src,
File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
throws IOException
cp with the -r option to operate recursively.
IOExceptionFile.copyAllTo(java.io.File, ArchiveDetector, ArchiveDetector),
File.archiveCopyAllTo(java.io.File, ArchiveDetector, ArchiveDetector),
Third Party
Access using different Archive Detectors
private static void cp_r0(boolean preserve,
File src,
File dst,
ArchiveDetector srcDetector,
ArchiveDetector dstDetector)
throws IOException
IOException
public static final void cp(boolean preserve,
File src,
File dst)
throws IOException
cp.
IOExceptionFile.cp(java.io.File, java.io.File),
File.cp_p(java.io.File, java.io.File),
Third Party
Access using different Archive Detectors
private static void cp0(boolean preserve,
File src,
File dst)
throws IOException
IOException
private static void cp0(boolean preserve,
File src,
InputStream in,
File dst)
throws IOException
FileNotFoundException - If either the source or the destination
cannot get accessed.
InputIOException - If copying the data fails because of an
IOException in the source.
IOException - If copying the data fails because of an
IOException in the destination.
private static void cp0(boolean preserve,
ArchiveController srcController,
String srcEntryName,
File dst)
throws IOException
Note that this method synchronizes on the class object in order to prevent dead locks by two threads copying archive entries to the other's source archive concurrently!
ArchiveController.FalsePositiveException - If the source or the destination is a
false positive and the exception
cannot get resolved within this method.
InputIOException - If copying the data fails because of an
IOException in the source.
IOException - If copying the data fails because of an
IOException in the destination.
private static void cp0(boolean preserve,
ArchiveController srcController,
String srcEntryName,
ArchiveController dstController,
String dstEntryName)
throws IOException
ArchiveController.FalsePositiveException - If the source or the destination is a
false positive and the exception for the destination
cannot get resolved within this method.
InputIOException - If copying the data fails because of an
IOException in the source.
IOException - If copying the data fails because of an
IOException in the destination.
static final void cp0(boolean preserve,
File src,
InputStream in,
ArchiveController dstController,
String dstEntryName)
throws IOException
Note that this method synchronizes on the class object in order to prevent dead locks by two threads copying archive entries to the other's source archive concurrently!
ArchiveController.FalsePositiveException - If the destination is a
false positive and the exception
cannot get resolved within this method.
InputIOException - If copying the data fails because of an
IOException in the source.
IOException - If copying the data fails because of an
IOException in the destination.
public static void cp(InputStream in,
OutputStream out)
throws IOException
IOExceptionFile.cp(InputStream, OutputStream)public static boolean rm_r(File file)
The name of this method is inspired by the Unix command line utility
rm with the -r option to operate recursively.
This file system operation is not atomic.
|
TrueZIP 6.8.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||