MIT licensed by Albert Krewinkel
Maintained by Albert Krewinkel
This version can be pinned in stack with:hslua-module-zip-1.1.3@sha256:c31bc4cb3d7e63a85e030b4c8938fcf35e8f49c20dad50067a9c40ce3c2481d6,3187

Module documentation for 1.1.3

hslua-module-zip

GitHub CI Hackage Stackage Lts Stackage Nightly MIT license

Lua module to work with file zips.

zip

Functions to create, modify, and extract files from zip archives.

The module can be called as a function, in which case it behaves like the zip function described below.

Zip options are optional; when defined, they must be a table with any of the following keys:

  • recursive: recurse directories when set to true;
  • verbose: print info messages to stdout;
  • destination: the value specifies the directory in which to extract;
  • location: value is used as path name, defining where files are placed.
  • preserve_symlinks: Boolean value, controlling whether symbolic links are preserved as such. This option is ignored on Windows.

Functions

Archive

Archive (bytestring_or_entries)

Reads an Archive structure from a raw zip archive or a list of Entry items; throws an error if the given string cannot be decoded into an archive.

Since: 1.0.0

Parameters:

bytestring_or_entries : (string|{ZipEntry,…})

Returns:

  • (ZipArchive)

Entry

Entry (path, contents[, modtime])

Generates a zip Entry from a filepath, the file’s uncompressed content, and the file’s modification time.

Since: 1.0.0

Parameters:

path : file path in archive (string)

contents : uncompressed contents (string)

modtime : modification time (integer)

read_entry

read_entry (filepath, opts)

Generates a ZipEntry from a file or directory.

Since: 1.0.0

Parameters:

filepath : (string)

opts : zip options (table)

Returns:

  • a new zip archive entry (ZipEntry)

zip

zip (filepaths[, options])

Package and compress the given files into a new Archive.

Since: 1.0.0

Parameters:

filepaths : list of files from which the archive is created. ({string,…})

options : zip options (table)

Returns:

  • a new archive (ZipArchive)

Types

Archive

A zip archive with file entries.

Fields

entries : files in this zip archive ({Entry,…})

Methods

extract([opts]) : Extract all files from this archive, creating directories as needed. Note that the last-modified time is set correctly only in POSIX, not in Windows. This function fails if encrypted entries are present.

Use `archive:extract{destination = 'dir'}` to extract to
subdirectory `dir`.

bytestring() : Returns the raw binary string representation of the archive.

Entry

File or directory entry in a zip archive.

Fields:

path : relative path, using / as separator

modtime : modification time (seconds since unix epoch)

Methods:

contents([password]) : Get the uncompressed contents of a zip entry. If password is given, then that password is used to decrypt the contents. An error is throws if decrypting fails.

Changes

Changelog

hslua-module-zips uses PVP Versioning.

hslua-module-zip-1.1.3

Released 2024-05-05.

  • Fix build on Windows. There are no symlinks on Windows; functions dealing with symlinks are missing from zip-archive and need a placeholder function.

hslua-module-zip-1.1.2

Released 2024-05-05.

  • Added a symlink method to Entry objects. This allows to check whether an entry represents a symbolic link, and where it links.

hslua-module-zip-1.1.1

Released 2024-01-18.

  • Relaxed upper bound for text, and filepath, allowing text-2.1, filepath-1.5.

hslua-module-zip-1.0.0

Released 2023-03-13.

  • Initially created.