## helma.Zip

    Object
       |
       +--helma.Zip

Instances of this class represent a single zip archive and provide various methods for extracting entries or manipulating the contents of the archive.
Defined in Zip.js
Author: Robert Gaggl

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`helma.Zip(<helma.File|java.io.File|String> file)` Constructs a new helma.Zip instance

Methods Summary
`void` | `add(<helma.File|java.io.File|String> f, <Number> level, <String> pathPrefix)` Adds a single file or a whole directory (recursive!) to the zip archive
`void` | `addData(<ByteArray> buf, <String> name, <Number> level)` Adds a new entry to the zip file.
`void` | `close()` Closes the zip archive.
`helma.Zip.Entry` | `extract(<String> name, <String> destPath)` Extracts a single file from the zip archive represented by this helma.Zip instance.
`helma.Zip.Content` | `extractAll(<String> destPath)` Extracts all files within the zip archive represented by this helma.Zip instance.
`ByteArray` | `getData()` Returns the binary data of the zip archive.
`helma.Zip.Content` | `list()` Returns an array containing the entries of the archive represented by this helma.Zip instance.
`void` | `save(<String> dest)` Saves the archive.
`<static> helma.Zip.Content` | `extractData(<ByteArray> zipData)` Extracts all files in the zip archive data passed as argument and returns them.

Constructor Detail

### helma.Zip

    helma.Zip(<helma.File|java.io.File|String> file)

Constructs a new helma.Zip instance

Parameters:

`file` - Either a file object representing the .zip file on disk, or the path to the .zip file as string.

Returns:

A newly created instance of helma.Zip.

Author: Robert Gaggl

Method Detail

### add

    void add(<helma.File|java.io.File|String> f, <Number> level, <String> pathPrefix)

Adds a single file or a whole directory (recursive!) to the zip archive

Parameters:

`f` - Either a file object or the path to a file or directory on disk that should be added to the archive. If the argument represents a directory, its contents will be added recursively to the archive.

`level` - An optional compression level to use. The argument must be between zero and 9 (default: 9 = best compression).

`pathPrefix` - An optional path prefix to use within the archive.

### addData

    void addData(<ByteArray> buf, <String> name, <Number> level)

Adds a new entry to the zip file.

Parameters:

`buf` - A byte array containing the data to add to the archive.

`name` - The name of the file to add, containing an optional path prefix

`level` - The compression level to use (0-9, defaults to 9).

### close

    void close()

Closes the zip archive. This method should be called when all operations have been finished, to ensure that no open file handles are left.

### extract

    helma.Zip.Entry extract(<String> name, <String> destPath)

Extracts a single file from the zip archive represented by this helma.Zip instance. If a destination path is given it writes the extracted data directly to disk using the name of the zip entry, otherwise the resulting entry object contains the extracted data in the property `data`.

Parameters:

`name` - The name of the file to extract

`destPath` - An optional destination path where the extracted file should be stored.

Returns:

An object containing the entry's properties

See:

- helma.Zip.Entry

### extractAll

    helma.Zip.Content extractAll(<String> destPath)

Extracts all files within the zip archive represented by this helma.Zip instance. If a destination path is given it stores the files directly on disk, while preserving any directory structure within the archive. If no destination path is given, the resulting entry objects will contain the extracted data in their property `data`.

Parameters:

`destPath` - An optional destination path where the files in the zip archive should be stored.

Returns:

An object containing the extracted entries.

See:

- helma.Zip.Entry

### getData

    ByteArray getData()

Returns the binary data of the zip archive.

Returns:

A ByteArray containing the binary data of the zip archive

### list

    helma.Zip.Content list()

Returns an array containing the entries of the archive represented by this helma.Zip instance.

Returns:

The entries stored in the zip archive

### save

    void save(<String> dest)

Saves the archive.

Parameters:

`dest` - The full destination path including the name where the zip archive should be saved.

### extractData

    <static> helma.Zip.Content extractData(<ByteArray> zipData)

Extracts all files in the zip archive data passed as argument and returns them.

Parameters:

`zipData` - A ByteArray containing the data of the zip archive

Returns:

The entries of the zip archive

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007