magus v0.3.0 is out. See what's new
¶ View markdown source · ✎ Suggest an edit
1 min read

archive

Archive creation and extraction with automatic format detection. Supports tar, zip, tar.gz, tar.bz2, tar.xz, and tar.zst. Symlinks and non-regular entries are skipped.

Naming convention: import the module under its bare name (import "archive"), reach members with a backslash, and call methods in camelCase: archive\someMethod.

Methods

uncompress

Extract the archive at src into dest. Returns a table with fields: files (extracted paths relative to dest) and bytes (total uncompressed bytes written). opts keys: strip (int, strip N leading path components), max_size (int, uncompressed byte cap, default 10 GiB), threads (int, parallel decode workers; 0 or omitted = auto).

Signature: archive\uncompress(src, dest, [opts]) → UncompressResult · source

Parameter Type Optional Description
src string
dest string
opts map[string]any yes

Returns: map[string]any

compress

Create an archive at dest from src (a file or directory). Format is inferred from dest extension (.tar, .tar.gz, .tgz, .tar.zst, .zip). Returns a table with fields: files (archived paths relative to src), bytes_in (raw bytes read), bytes_out (compressed bytes written). opts keys: format (string, override format detection), threads (int, parallel encode workers; 0 or omitted = auto), level (int, compression level; -1 = format default), follow_symlinks (bool, default false), max_size (int, output byte cap, default 10 GiB).

Signature: archive\compress(src, dest, [opts]) → CompressResult · source

Parameter Type Optional Description
src string
dest string
opts map[string]any yes

Returns: map[string]any

auto-generatedarchivemodulestdlibmagusfile
Last updated (63b34b40)
Earlier changes on this page (2)

Full history ↗ · Blame source ↗

Glossary

Magusfile

The magusfile.buzz that declares a project's targets (as export funs) and binds its spells. See targets.

Module

A magus stdlib namespace a magusfile imports for host capabilities: filesystem, exec, vcs, and more. See the module reference.

Conventions

This page uses none of the site's convention markers. The full set is on the conventions page.