{ } qjs-modules

archive

Source: quickjs-archive.c — module exports Archive, ArchiveEntry, ArchiveMatch

Reading and writing archive files (wraps libarchive): tar, zip, cpio, and the compression filters libarchive supports. An Archive is iterable over its entries.

Archive

new Archive()   // length 1

Methods

MethodArgsDescription
open(filename)1Opens an archive for reading.
read(buffer)1Reads archive data from a buffer.
write(filename)1Opens an archive for writing.
next()0Advances to the next entry; returns an ArchiveEntry.
skip()0Skips the current entry's data.
seek(offset, whence)2Seeks within the archive.
extract(flags)1Extracts the current entry to disk.
filterBytes(data)1Runs data through the archive's filters.
close()0Closes the archive.
[Symbol.iterator]()0Iterates entries.

Properties

PropertyKindDescription
errno / errorgetterLast libarchive error code / string.
formatgetter/setterArchive format.
compressiongetterCompression method.
filtersgetterActive filter chain.
positiongetterCurrent byte position.
readHeaderPositiongetterHeader read position.
hasEncryptedEntriesgetterWhether encrypted entries are present.
blockSizegetter/setterI/O block size.
fileCountgetterNumber of entries.

Static members

MemberArgsKindDescription
read(filename)1functionOpens an archive for reading in one call.
write(filename)1functionOpens an archive for writing in one call.
version—getterlibarchive version.

ArchiveEntry

new ArchiveEntry()   // length 1

clone() plus read/write metadata accessors: atime, ctime, mtime, birthtime, dev, devmajor, devminor, rdev, rdevmajor, rdevminor, filetype, type, fflags, uid, gid, ino, nlink, pathname (enumerable), uname, gname, mode, perm, size (enumerable), symlink, hardlink, link, isDataEncrypted, isMetadataEncrypted, isEncrypted.

ArchiveMatch

new ArchiveMatch()   // length 1

include(pattern) and exclude(pattern) build path-matching filters for selective extraction.