Module jls.util.zip.ZipFile

Provide ZIP file utility.

ZIP files are archives that allow to store and compress multiple files. The goal is to provide a minimal implementation compatible with the ZIP format. The file storage methods are deflated and stored. The encryption and multiple volumes features are not supported. Note that CRC32 is not verified.

Class ZipFile

ZipFile:new (file[, create[, overwrite]]) Creates a new ZipFile with the specified file or filename.
zipFile:close () Closes this ZIP file
zipFile:getEntries () Returns the entries of this ZIP file.
zipFile:getEntry (name) Returns the entry for the specified name.
zipFile:getContentSync (entry) Returns the content of the specified entry.
zipFile:getContent (entry[, stream[, async]]) Returns the content of the specified entry.
ZipFile.unzipToSync (file, directory[, adaptFileName]) Extracts files from a ZIP file.
ZipFile.zipToSync (file, files[, overwrite[, path]]) Creates a ZIP file containing the specified files.
ZipFile.zipToAsync (file, files[, overwrite[, path]]) Creates a ZIP file containing the specified files.


Class ZipFile

The ZipFile class. A ZipFile instance represents a ZIP file.
ZipFile:new (file[, create[, overwrite]])
Creates a new ZipFile with the specified file or filename.

Parameters:

  • file File the zip file.
  • create boolean true to indicate that the zip file shall be created (optional)
  • overwrite boolean true to indicate that the zip file shall be overwrited (optional)
zipFile:close ()
Closes this ZIP file
zipFile:getEntries ()
Returns the entries of this ZIP file.

Returns:

    table the entries.
zipFile:getEntry (name)
Returns the entry for the specified name.

Parameters:

Returns:

    the entry
zipFile:getContentSync (entry)
Returns the content of the specified entry.

Parameters:

  • entry the entry

Returns:

    string the entry content
zipFile:getContent (entry[, stream[, async]])
Returns the content of the specified entry.

Parameters:

  • entry the entry
  • stream StreamHandler an optional jls.io.StreamHandler that will be called with the content. (optional)
  • async boolean true to get the consent asynchronously. (optional)

Returns:

    string the entry content
ZipFile.unzipToSync (file, directory[, adaptFileName])
Extracts files from a ZIP file.

Parameters:

  • file File the zip file.
  • directory File the directory to extract files to.
  • adaptFileName function a function that will be call for each entry to adapt the extracted filename. (optional)
ZipFile.zipToSync (file, files[, overwrite[, path]])
Creates a ZIP file containing the specified files.

Parameters:

  • file File the zip file.
  • files the directory or files to include
  • overwrite boolean true to indicate that the zip file shall be overwrited (optional)
  • path string the base path in the zip file, default to the empty string (optional)
ZipFile.zipToAsync (file, files[, overwrite[, path]])
Creates a ZIP file containing the specified files.

Parameters:

  • file File the zip file.
  • files the directory or files to include
  • overwrite boolean true to indicate that the zip file shall be overwrited (optional)
  • path string the base path in the zip file, default to the empty string (optional)

Returns:

    jls.lang.Promise a promise that resolves once the ZIP file as been created.
generated by LDoc 1.4.6