Skip to content

Commit 701dffd

Browse files
committed
zlib: add ZipEntry, ZipFile, and ZipBuffer
Add ZIP archive support to the node:zlib module through three classes and a set of helpers: - ZipEntry: a single archive member, with buffered reads (content()), bounded-memory streaming reads (contentIterator()), and create()/createStream() for building members. - ZipFile: random access to an archive backed by a file descriptor, reading members lazily without retaining their content and writing new members in place; opened with open()/openSync(). - ZipBuffer: a zero-copy, in-memory view over an archive already held in a Buffer. createZipArchive() serializes a sequence of entries into an archive byte stream, and setMaxZipContentSize() bounds the default in-memory decompression size. Every operation has both an asynchronous and a synchronous form. Signed-off-by: Philipp Dunkel <pip@pipobscure.com>
1 parent 1912893 commit 701dffd

16 files changed

Lines changed: 5826 additions & 0 deletions

doc/api/errors.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3674,6 +3674,50 @@ All attempts at serializing an uncaught exception from a worker thread failed.
36743674

36753675
The requested functionality is not supported in worker threads.
36763676

3677+
<a id="ERR_ZIP_ENTRY_CORRUPT"></a>
3678+
3679+
### `ERR_ZIP_ENTRY_CORRUPT`
3680+
3681+
A ZIP archive entry failed CRC-32 verification, or produced more or fewer
3682+
bytes than its declared uncompressed size, while being read.
3683+
3684+
<a id="ERR_ZIP_ENTRY_NOT_FOUND"></a>
3685+
3686+
### `ERR_ZIP_ENTRY_NOT_FOUND`
3687+
3688+
A named entry was requested from a [`ZipFile`][] or [`ZipBuffer`][] that does
3689+
not contain an entry with that name.
3690+
3691+
<a id="ERR_ZIP_ENTRY_TOO_LARGE"></a>
3692+
3693+
### `ERR_ZIP_ENTRY_TOO_LARGE`
3694+
3695+
A ZIP archive entry's declared size exceeds the configured limit, or a
3696+
provided entry name or comment exceeds the 65,535-byte encoded length that
3697+
the ZIP format allows.
3698+
3699+
<a id="ERR_ZIP_INVALID_ARCHIVE"></a>
3700+
3701+
### `ERR_ZIP_INVALID_ARCHIVE`
3702+
3703+
Data that was expected to be a ZIP archive, or a structure within one, is
3704+
missing, out of bounds, or otherwise inconsistent with the ZIP format.
3705+
3706+
<a id="ERR_ZIP_NOT_WRITABLE"></a>
3707+
3708+
### `ERR_ZIP_NOT_WRITABLE`
3709+
3710+
A mutating method (such as `zipFile.addEntry()` or `zipFile.delete()`) was
3711+
called on a [`ZipFile`][] that was not opened with `{ writable: true }`.
3712+
3713+
<a id="ERR_ZIP_UNSUPPORTED_FEATURE"></a>
3714+
3715+
### `ERR_ZIP_UNSUPPORTED_FEATURE`
3716+
3717+
A ZIP archive uses a feature outside of what this implementation supports,
3718+
such as entry encryption, an unsupported compression method, or a multi-disk
3719+
archive.
3720+
36773721
<a id="ERR_ZLIB_INITIALIZATION_FAILED"></a>
36783722

36793723
### `ERR_ZLIB_INITIALIZATION_FAILED`
@@ -4617,6 +4661,8 @@ An error occurred trying to allocate memory. This should never happen.
46174661
[`ServerResponse`]: http.md#class-httpserverresponse
46184662
[`Temporal`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal
46194663
[`Writable`]: stream.md#class-streamwritable
4664+
[`ZipBuffer`]: zlib.md#class-zlibzipbuffer
4665+
[`ZipFile`]: zlib.md#class-zlibzipfile
46204666
[`child_process`]: child_process.md
46214667
[`cipher.getAuthTag()`]: crypto.md#ciphergetauthtag
46224668
[`crypto.getDiffieHellman()`]: crypto.md#cryptogetdiffiehellmangroupname

0 commit comments

Comments
 (0)