Fields and methods of the helma.Zip class.
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Zip.js')
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Zip.js')
Constructs a new helma.Zip instance
parameters
helma.File, java.io.File, String | file | Either a file object representing the .zip file on disk, or the path to the .zip file as string. |
methods
- list()
- extract(name, destPath)
- extractAll(destPath)
- add(f, level, pathPrefix)
- addData(buf, name, level)
- close()
- getData()
- save(dest)
Creates a new instance of helma.Zip.Entry
parameters
java.util.zip.ZipEntry | entry | The zip entry object whose metadata should be stored in this instance |
properties
- String name
- Number size
- Date time
- Boolean isDirectory
- ByteArray data
The table of contents of the archive
The files contained in the zip archive, where
each directory level is a separate object containing
the entries (files and directories) as properties.
The name of the zip archive entry
The size of the entry in bytes
The file date of the entry
True if the entry is a directory, false otherwise
The data of the zip entry
Methods
Returns an array containing the entries of the archive
represented by this helma.Zip instance.
returns
The entries stored in the zip archive |
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
String | name | The name of the file to extract |
String | destPath | An optional destination path where the extracted file should be stored. |
returns
An object containing the entry's properties |
see
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
String | destPath | An optional destination path where the files in the zip archive should be stored. |
returns
An object containing the extracted entries. |
see
Adds a single file or a whole directory (recursive!) to the zip archive
parameters
helma.File, java.io.File, String | 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. |
Number | level | An optional compression level to use. The argument must be between zero and 9 (default: 9 = best compression). |
String | pathPrefix | An optional path prefix to use within the archive. |
Adds a new entry to the zip file.
parameters
ByteArray | buf | A byte array containing the data to add to the archive. |
String | name | The name of the file to add, containing an optional path prefix |
Number | level | The compression level to use (0-9, defaults to 9). |
Closes the zip archive. This method should be called when
all operations have been finished, to ensure that no open
file handles are left.
Returns the binary data of the zip archive.
returns
A ByteArray containing the binary data of the zip archive |
Saves the archive.
parameters
String | dest | The full destination path including the name where the zip archive should be saved. |
Adds a zip entry object to the table of contents
and the files collection
parameters
helma.Zip.Entry | entry | The entry to add to the zip archive |
Extracts all files in the zip archive data passed as argument
and returns them.
parameters
ByteArray | zipData | A ByteArray containing the data of the zip archive |
returns
The entries of the zip archive |