Commit c7a3f01
committed
zlib: add ZIP archive read/write support
Adds ZipEntry, ZipFile, and ZipBuffer to node:zlib for reading, creating,
and mutating ZIP archives, reusing the existing deflate/zstd bindings
rather than adding new native code.
ZipEntry reads and builds individual archive members (store, deflate, and
zstd compression), with a streaming variant for producing content
incrementally and synchronous counterparts for every method, documented
as event-loop-blocking (mirroring node:fs).
ZipBuffer is an in-memory, always-writable view over an archive buffer:
entries can be added, replaced, or deleted, and toBuffer()/toBufferSync()
serialize the current live set into a fresh archive.
ZipFile is a disk-backed archive, read-only by default and writable when
opened with { writable: true }. Writes append new entries where the
central directory used to be and rewrite the central directory in place;
deletions rewrite the central directory only, without growing the file.
compact()/compactSync() stream a fresh archive with no dead entries left
behind. An internal busy-flag counter prevents synchronous methods from
running while an asynchronous mutation hasn't settled yet, since both
would otherwise compute the same central-directory offset.
Also adds six ERR_ZIP_* error codes and getMaxZipContentSize()/
setMaxZipContentSize() to bound decompressed entry size by default.1 parent f91697a commit c7a3f01
15 files changed
Lines changed: 4742 additions & 0 deletions
File tree
- doc/api
- lib
- internal
- test
- parallel
- pummel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3674 | 3674 | | |
3675 | 3675 | | |
3676 | 3676 | | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + | |
| 3699 | + | |
| 3700 | + | |
| 3701 | + | |
| 3702 | + | |
| 3703 | + | |
| 3704 | + | |
| 3705 | + | |
| 3706 | + | |
| 3707 | + | |
| 3708 | + | |
| 3709 | + | |
| 3710 | + | |
| 3711 | + | |
| 3712 | + | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
| 3718 | + | |
| 3719 | + | |
| 3720 | + | |
3677 | 3721 | | |
3678 | 3722 | | |
3679 | 3723 | | |
| |||
4674 | 4718 | | |
4675 | 4719 | | |
4676 | 4720 | | |
| 4721 | + | |
| 4722 | + | |
4677 | 4723 | | |
4678 | 4724 | | |
4679 | 4725 | | |
| |||
0 commit comments