de.schlichtherle.truezip.sample.file.app
Class Nzip
java.lang.Object
de.schlichtherle.truezip.file.TApplication<RuntimeException>
de.schlichtherle.truezip.sample.file.app.Application
de.schlichtherle.truezip.sample.file.app.Nzip
@DefaultAnnotation(value=edu.umd.cs.findbugs.annotations.NonNull.class)
public class Nzip
- extends Application
A comprehensive command line utility which allows you to work
with entries in all supported archive files using Unix like commands
(cat, cp, rm, mkdir,
rmdir, ls etc.).
Please note that TrueZIP is designed for optimum performance.
However, this utility features some optional archive drivers which
provide additional safety or otherwise unavailable features.
Some of these drivers are not used in their default configuration -
see TArchiveDetector for more
information.
For example, the ZIP drivers used in this utility always check
the CRC-32 values provided in the ZIP file.
In addition, the SFX driver is used which allows you to browse
.exe files if they happen to be SelF eXtracting archives (SFX).
If they are not however, TrueZIP may spend some considerable amount of
time searching for the Central Directory required to be present in ZIP
(and hence SFX) files.
As a conclusion, this utility should not serve as a performance benchmark.
This class is not thread safe.
- Author:
- Christian Schlichtherle
|
Constructor Summary |
Nzip()
|
|
Method Summary |
private void |
align(StringBuffer buf,
long number,
int spacing)
|
private void |
cat(String[] args)
|
private void |
cpOrMv(String[] args,
boolean mv)
|
private boolean |
exists(String[] args)
|
private boolean |
isArchive(String[] args)
|
private boolean |
isDirectory(String[] args)
|
private boolean |
isFile(String[] args)
|
private boolean |
length(String[] args)
|
private void |
ls(String[] args,
boolean detailed,
boolean recursive)
|
private void |
ls(TFile file,
String path,
boolean detailed)
|
private void |
ls(TFile file,
String path,
boolean detailed,
boolean recursive)
Lists the given file with the given display path. |
private static String[] |
lshift(String[] args)
|
private static String[] |
lshift(String[] args,
int num)
|
static void |
main(String[] args)
Equivalent to System.exit(new Nzip().run(args));. |
private void |
mkdir(String[] args,
boolean recursive)
|
protected TArchiveDetector |
newArchiveDetector()
May be overridden by subclasses to create the
TArchiveDetector which provides file system drivers which
should use the specified charset if supported. |
protected TArchiveDetector |
newArchiveDetector(Charset charset)
|
private void |
rm(String[] args,
boolean recursive)
|
protected int |
runChecked(String[] args)
Runs this command line utility. |
private void |
touch(String[] args)
|
| Methods inherited from class de.schlichtherle.truezip.file.TApplication |
run |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CLASS_NAME
private static final String CLASS_NAME
resources
private static final ResourceBundle resources
POOL_PROVIDER
private static final IOPoolProvider POOL_PROVIDER
numberFormat
private final NumberFormat numberFormat
dateFormat
private final DateFormat dateFormat
fpos
private final FieldPosition fpos
Nzip
public Nzip()
newArchiveDetector
protected TArchiveDetector newArchiveDetector()
- May be overridden by subclasses to create the
TArchiveDetector which provides file system drivers which
should use the specified charset if supported.
Note that the archive detector which is returned by the implementation
in this class uses some archive drivers which may be pretty slow due to
some extra compatibility tests which they perform on every archive.
newArchiveDetector
protected TArchiveDetector newArchiveDetector(Charset charset)
- See Also:
newArchiveDetector()
main
public static void main(String[] args)
throws FsSyncException
- Equivalent to
System.exit(new Nzip().run(args));.
- Throws:
FsSyncException
runChecked
protected int runChecked(String[] args)
throws Nzip.IllegalUsageException,
IOException
- Runs this command line utility.
Throws an exception if an error occurs.
- Specified by:
runChecked in class Application
- Parameters:
args - A non-empty array of Unix-like commands and optional
parameters.
- Returns:
false iff the command is a test which fails,
true otherwise.
- Throws:
Nzip.IllegalUsageException - If args does not contain
correct commands or parameters.
IOException - On any I/O related exception.
lshift
private static String[] lshift(String[] args)
lshift
private static String[] lshift(String[] args,
int num)
ls
private void ls(String[] args,
boolean detailed,
boolean recursive)
throws IOException
- Throws:
IOException
ls
private void ls(TFile file,
String path,
boolean detailed,
boolean recursive)
throws IOException
- Lists the given file with the given display path.
- Throws:
IOException
ls
private void ls(TFile file,
String path,
boolean detailed)
align
private void align(StringBuffer buf,
long number,
int spacing)
cat
private void cat(String[] args)
throws Nzip.IllegalUsageException,
IOException
- Throws:
Nzip.IllegalUsageException
IOException
cpOrMv
private void cpOrMv(String[] args,
boolean mv)
throws Nzip.IllegalUsageException,
IOException
- Throws:
Nzip.IllegalUsageException
IOException
touch
private void touch(String[] args)
throws Nzip.IllegalUsageException,
IOException
- Throws:
Nzip.IllegalUsageException
IOException
mkdir
private void mkdir(String[] args,
boolean recursive)
throws Nzip.IllegalUsageException,
IOException
- Throws:
Nzip.IllegalUsageException
IOException
rm
private void rm(String[] args,
boolean recursive)
throws Nzip.IllegalUsageException,
IOException
- Throws:
Nzip.IllegalUsageException
IOException
isArchive
private boolean isArchive(String[] args)
throws Nzip.IllegalUsageException
- Throws:
Nzip.IllegalUsageException
isDirectory
private boolean isDirectory(String[] args)
throws Nzip.IllegalUsageException
- Throws:
Nzip.IllegalUsageException
isFile
private boolean isFile(String[] args)
throws Nzip.IllegalUsageException
- Throws:
Nzip.IllegalUsageException
exists
private boolean exists(String[] args)
throws Nzip.IllegalUsageException
- Throws:
Nzip.IllegalUsageException
length
private boolean length(String[] args)
throws Nzip.IllegalUsageException
- Throws:
Nzip.IllegalUsageException
Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.