mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
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> PR-URL: https://github.com/nodejs/node/pull/64339 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
// Public entry point for ZIP archive support in `node:zlib`. The
|
|
// implementation is split across `internal/zip/`:
|
|
//
|
|
// constants shared signatures, flags, symbols, and small values
|
|
// binary bounds-checked reads and buffer coercion
|
|
// content-size the module-global in-memory decompression ceiling
|
|
// dos MS-DOS date/time and CP437 legacy name/text decoding
|
|
// extra-fields TLV extra-field parsing and building
|
|
// headers reader-side header structures and archive-end location
|
|
// header-builders writer-side header/record builders
|
|
// compression deflate/inflate/zstd plumbing and member decoding
|
|
// fs-util fd read/write helpers
|
|
// entry ZipEntry
|
|
// archive createZipArchive()/zipFiles() serialization
|
|
// buffer ZipBuffer
|
|
// file ZipFile
|
|
//
|
|
// This barrel re-exports only the surface `lib/zlib.js` consumes.
|
|
|
|
const { ZipEntry } = require('internal/zip/entry');
|
|
const { ZipBuffer } = require('internal/zip/buffer');
|
|
const { ZipFile } = require('internal/zip/file');
|
|
const {
|
|
createZipArchive,
|
|
createZipArchiveSync,
|
|
zipFiles,
|
|
} = require('internal/zip/archive');
|
|
const {
|
|
getMaxZipContentSize,
|
|
setMaxZipContentSize,
|
|
} = require('internal/zip/content-size');
|
|
|
|
module.exports = {
|
|
ZipEntry,
|
|
ZipFile,
|
|
ZipBuffer,
|
|
createZipArchive,
|
|
createZipArchiveSync,
|
|
zipFiles,
|
|
getMaxZipContentSize,
|
|
setMaxZipContentSize,
|
|
};
|