TrueZIP 6.8.2

de.schlichtherle.io.samples
Class NZip

java.lang.Object
  extended by de.schlichtherle.io.samples.CommandLineUtility
      extended by de.schlichtherle.io.samples.NZip

public class NZip
extends CommandLineUtility

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 DefaultArchiveDetector 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.

Since:
TrueZIP 6.5
Version:
$Id: NZip.java c86df83eaddc 2011/01/19 13:52:55 christian $
Author:
Christian Schlichtherle

Nested Class Summary
 class NZip.IllegalUsageException
           
 
Nested classes/interfaces inherited from class de.schlichtherle.io.samples.CommandLineUtility
CommandLineUtility.ProgressMonitor
 
Field Summary
private static String CLASS_NAME
           
private  DateFormat dateFormat
           
private  FieldPosition fpos
           
private  NumberFormat numberFormat
           
private static ResourceBundle resources
           
 
Fields inherited from class de.schlichtherle.io.samples.CommandLineUtility
err, out, progressMonitor
 
Constructor Summary
NZip()
           
NZip(OutputStream out, OutputStream err, boolean autoFlush)
           
 
Method Summary
private  void align(StringBuffer buf, long number, int spacing)
           
private  void cat(String[] args)
           
private  void cpOrMv(String[] args, boolean mv)
           
protected  DefaultArchiveDetector createDefaultArchiveDetector()
          May be overridden by subclasses to create the ArchiveDetector which shall be used as the default archive detector while a command is running.
protected  DefaultArchiveDetector createDefaultArchiveDetector(String charset)
          May be overridden by subclasses to create the ArchiveDetector which returns ArchiveDrivers which should use the specified charset if supported.
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(File file, String path, boolean detailed)
           
private  void ls(File file, String path, boolean detailed, boolean recursive)
          Lists the given file with the given display path.
private  void ls(String[] args, boolean detailed, boolean recursive)
           
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)
           
private  void rm(String[] args, boolean recursive)
           
 boolean runWithException(String[] args)
          Runs this command line utility.
private  void touch(String[] args)
           
 
Methods inherited from class de.schlichtherle.io.samples.CommandLineUtility
run
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

private static final String CLASS_NAME
See Also:
Constant Field Values

resources

private static final ResourceBundle resources

numberFormat

private final NumberFormat numberFormat

dateFormat

private final DateFormat dateFormat

fpos

private final FieldPosition fpos
Constructor Detail

NZip

public NZip()

NZip

public NZip(OutputStream out,
            OutputStream err,
            boolean autoFlush)
Method Detail

createDefaultArchiveDetector

protected DefaultArchiveDetector createDefaultArchiveDetector()
May be overridden by subclasses to create the ArchiveDetector which shall be used as the default archive detector while a command is running. The ArchiveDrivers returned by the archive detector should use their default charsets.

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.


createDefaultArchiveDetector

protected DefaultArchiveDetector createDefaultArchiveDetector(String charset)
May be overridden by subclasses to create the ArchiveDetector which returns ArchiveDrivers which should use the specified charset if supported. This is used by selected commands in this class.

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.


main

public static void main(String[] args)
Equivalent to System.exit(new NZip().run(args));.


runWithException

public boolean runWithException(String[] args)
                         throws NZip.IllegalUsageException,
                                IOException
Runs this command line utility. Throws an exception if an error occurs.

Specified by:
runWithException in class CommandLineUtility
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 final 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(File file,
                String path,
                boolean detailed,
                boolean recursive)
         throws IOException
Lists the given file with the given display path.

Throws:
IOException

ls

private void ls(File file,
                String path,
                boolean detailed)

align

private void align(StringBuffer buf,
                   long number,
                   int spacing)

cat

private void cat(String[] args)
          throws IOException
Throws:
IOException

cpOrMv

private void cpOrMv(String[] args,
                    boolean mv)
             throws IOException
Throws:
IOException

touch

private void touch(String[] args)
            throws IOException
Throws:
IOException

mkdir

private void mkdir(String[] args,
                   boolean recursive)
            throws IOException
Throws:
IOException

rm

private void rm(String[] args,
                boolean recursive)
         throws IOException
Throws:
IOException

isArchive

private boolean isArchive(String[] args)

isDirectory

private boolean isDirectory(String[] args)

isFile

private boolean isFile(String[] args)

exists

private boolean exists(String[] args)

length

private boolean length(String[] args)

TrueZIP 6.8.2

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.