Constructor
new Zip(file)
Constructs a new helma.Zip instance
Parameters:
Name | Type | Description |
---|---|---|
file |
helma.File | java.io.File | String | Either a file object representing the .zip file on disk, or the path to the .zip file as string. |
- Source:
Returns:
A newly created instance of helma.Zip.
Classes
Members
(inner) tempFile
constructor body
- Source:
Methods
add(f, level, pathPrefix)
Adds a single file or a whole directory (recursive!) to the zip archive
Parameters:
Name | Type | Description |
---|---|---|
f |
helma.File | java.io.File | String | 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 |
Number | An optional compression level to use. The argument must be between zero and 9 (default: 9 = best compression). |
pathPrefix |
String | An optional path prefix to use within the archive. |
- Source:
addData(buf, name, level)
Adds a new entry to the zip file.
Parameters:
Name | Type | Description |
---|---|---|
buf |
ByteArray | A byte array containing the data to add to the archive. |
name |
String | The name of the file to add, containing an optional path prefix |
level |
Number | The compression level to use (0-9, defaults to 9). |
- Source:
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.
- Source:
extract(name, 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 | Type | Description |
---|---|---|
name |
String | The name of the file to extract |
destPath |
String | An optional destination path where the extracted file should be stored. |
- Source:
- See:
Returns:
An object containing the entry's properties
extractAll(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:
Name | Type | Description |
---|---|---|
destPath |
String | An optional destination path where the files in the zip archive should be stored. |
- Source:
- See:
Returns:
An object containing the extracted entries.
getData()
Returns the binary data of the zip archive.
- Source:
Returns:
A ByteArray containing the binary data of the zip archive
list()
Returns an array containing the entries of the archive
represented by this helma.Zip instance.
- Source:
Returns:
The entries stored in the zip archive
save(dest)
Saves the archive.
Parameters:
Name | Type | Description |
---|---|---|
dest |
String | The full destination path including the name where the zip archive should be saved. |
- Source:
(static) extractData(zipData)
Extracts all files in the zip archive data passed as argument
and returns them.
Parameters:
Name | Type | Description |
---|---|---|
zipData |
ByteArray | A ByteArray containing the data of the zip archive |
- Source:
Returns:
The entries of the zip archive