Skip to content

tyrus:archive types ​

Types must be imported by name

ArchiveEntry, ArchiveEntryKind, ArchiveError, ArchiveFormat, ArchiveSummary, PackOptions, and UnpackOptions must be imported explicitly whenever their fields, members, or object literals are used.

ArchiveSummary ​

ArchiveSummary is returned by pack and unpack.

FieldTypeDescription
entriesu64Files and directories written.
bytesu64Uncompressed file bytes written.

ArchiveEntry ​

ArchiveEntry is returned by list.

FieldTypeDescription
namestringThe entry name exactly as the archive stores it. Directory names end with / in ZIP archives.
kindArchiveEntryKindWhat the entry is.
sizeu64Uncompressed size in bytes.
compressedSizeu64?Compressed size in bytes for ZIP entries; absent for TAR entries.

ArchiveEntryKind ​

MemberMeaning
FileA regular file.
DirectoryA directory.
SymlinkA symbolic link. unpack refuses it.
HardLinkA hard link. unpack refuses it.
OtherA device, pipe, or other special entry. unpack refuses it.
tyrus
import { ArchiveEntry, ArchiveEntryKind, ArchiveError, list } from "tyrus:archive";

async function hasLinks(): Promise<Result<boolean, ArchiveError>> {
    const entries: ArchiveEntry[] = await list("./upload.tar")?;
    return Ok(entries.some((entry: ArchiveEntry): boolean => entry.kind === ArchiveEntryKind.Symlink));
}

ArchiveFormat ​

The format packStream writes, since a stream has no extension to decide it.

MemberFormat
ZipZIP, with data descriptors.
TarTAR, uncompressed.
TarGzTAR compressed with Gzip.

PackOptions ​

FieldTypeDefault
leveli32?6
overwriteboolean?false
excludestring[]?none
prefixstring?none
reproducibleboolean?false
timeoutMsu64?600000

See pack for what each option does.

UnpackOptions ​

FieldTypeDefault
overwriteboolean?false
stripComponentsu32?0
maxEntriesu64?100000
maxBytesu64?4 GiB
maxRatiou32?200
timeoutMsu64?600000

See unpack for what each option does.

ArchiveError ​

ArchiveError is the recoverable error of every archive operation, delivered as the Err of the Result each function resolves with.

FieldTypeDescription
codestringStable identifier, such as ERR_ARCHIVE_PATH_ESCAPE. See the error codes.
messagestringHuman-readable description.
entrystring?The archive entry or source path that caused the failure, when there is one, truncated to 4 KiB.
tyrus
import { ArchiveError, ArchiveSummary, unpack } from "tyrus:archive";

async function extract(): Promise<void> {
    const result: Result<ArchiveSummary, ArchiveError> = await unpack("./upload.zip", "./out");
    match (result) {
        Ok(summary) => { print(summary.entries); }
        Err(error) => {
            printError(error.code); // ERR_ARCHIVE_UNSAFE_LINK
            printError(error.entry ?? ""); // docs/latest
        }
    }
}