Module basic module

Module zip

zip format file compression and decompression module

Instructions:

1
var zip = require('zip');

Static function

isZipFile

Determine whether the file is in zip format

1
static Boolean zip.isZipFile(String filename) async;

Call parameters:

  • filename: String, file name

Return result:

  • Boolean, Return true to indicate that the file is a zip file

open

Open a zip file

1 2 3
static ZipFile zip.open(String path, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • path: String, file path
  • mod: String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type: Integer, compression type, ZIP_STORED means no compression, only storage. ZIP_DEFLATED is used by default, which means it is usedzlibThe library is compressed.

Return result:

  • ZipFile, Return the zip file object

Open a zip file

1 2 3
static ZipFile zip.open(Buffer data, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • data: Buffer, zip file data
  • mod: String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type: Integer, compression type, ZIP_STORED means no compression, only storage. ZIP_DEFLATED is used by default, which means it is usedzlibThe library is compressed.

Return result:

  • ZipFile, Return the zip file object

Open a zip file

1 2 3
static ZipFile zip.open(SeekableStream strm, String mod = "r", Integer compress_type = ZIP_DEFLATED) async;

Call parameters:

  • strm: SeekableStream, zip file stream
  • mod: String, open file mode, "r" means read, "w" means create, "a" means append after zip file
  • compress_type: Integer, compression type, ZIP_STORED means no compression, only storage. ZIP_DEFLATED is used by default, which means it is usedzlibThe library is compressed.

Return result:

  • ZipFile, Return the zip file object

constant

ZIP_STORED

Compression type constant, no compression, storage only

1
const zip.ZIP_STORED = 0;

ZIP_DEFLATED

Compression type constant, need to depend onzlibLibrary compression

1
const zip.ZIP_DEFLATED = 1;