Skip to content

l0.DependencyControl.ZipArchiver

ZipArchiver = require "l0.DependencyControl.ZipArchiver"
local ZipArchiver = require("l0.DependencyControl.ZipArchiver")

ZipArchiver

Builds zip archives using each platform's stock tooling — no extra rocks or shared libraries to install or locate. Files are added with explicit, forward-slash entry names so the resulting archives extract correctly on every platform. Compression only for now; reading/extraction can be added when needed.

archiver = ZipArchiver outputPath
archiver\addDirectory distDir
archiver\addFile readmePath, "README.md"
success, err = archiver\write!

Constructor

zipArchiver = ZipArchiver outputPath, logger
local zipArchiver = ZipArchiver(outputPath, logger)

Creates an archiver that will write a zip to outputPath.

param type description
outputPath string Absolute path of the archive to create.
logger? Logger

Instance methods

addFile

zipArchiver\addFile sourcePath, archiveName
zipArchiver:addFile(sourcePath, archiveName)

Adds a single file under archiveName (a forward-slash path within the archive).

param type description
sourcePath string Absolute path of the file to add.
archiveName string Name/path the file should have inside the archive.

Returns:

addDirectory

zipArchiver\addDirectory sourceDir, archivePrefix
zipArchiver:addDirectory(sourceDir, archivePrefix)

Adds every file beneath sourceDir, naming each entry by its path relative to sourceDir (optionally below archivePrefix).

param type description
sourceDir string Absolute path of the directory to add.
archivePrefix? string Optional path prefix for the entries inside the archive.

Returns:

write

zipArchiver\write!
zipArchiver:write()

Writes the archive to outputPath. Returns true on success, or nil plus an error message.

Returns:

  • success boolean|nil
  • err string|nil