Capy-Bearer Documentation

zip_create

lib call

Capy

function zip_create(path : string, entries : any) any

Description

zip_create() creates a ZIP archive from an any map of entry names and content. Content strings contain raw bytes. The archive path is a file path, not an in-memory archive string. An existing archive is replaced, not appended.

Each entry can also be a descriptor map with name and either content or file. name overrides the map key. content takes priority over file. The file field reads bytes from a source path. Without either field, the value converts to a string. An unreadable source file returns a failure.

Names must be relative. Backslashes become slashes. Absolute names, colons, control bytes, and .. components are rejected. Missing archive parent directories are created.

Creation errors and configured limits return a failure. Default limits are 4,096 entries and 64 MiB of content per entry.

Parameters

path : archive path

entries : archive entries

Return Values

{ok: true, error: ""} on success, or {ok: false, error: "..."} on failure.

Example

Capy

var archive := file_temp()
zip_create(archive, {"note.txt": "hello"})
print(zip_read(archive, "note.txt").value ?? "", "\n")

Output

hello