zip

zip 格式文件压缩解压模块

使用方法:

var zip = require('zip');

Field Summary

Type Method and Description
const public const ZIP_STOREDZIP_STOREDZIP_STORED

压缩类型常量, 不压缩, 仅存储

const public const ZIP_DEFLATEDZIP_DEFLATEDZIP_DEFLATED

压缩类型常量, 需要依赖zlib库进行压缩

Method Summary

Type Method and Description
Boolean isZipFile(String filename)

判断文件是否是zip格式

ZipFile open(String path,String mod,Integer compress_type)

打开一个zip文件

ZipFile open(Buffer data,String mod,Integer compress_type)

打开一个zip文件

ZipFile open(SeekableStream strm,String mod,Integer compress_type)

打开一个zip文件

Field Detail

ZIP_STORED

const public const ZIP_STOREDZIP_STOREDZIP_STORED

压缩类型常量, 不压缩, 仅存储

ZIP_DEFLATED

const public const ZIP_DEFLATEDZIP_DEFLATEDZIP_DEFLATED

压缩类型常量, 需要依赖zlib库进行压缩

Method Detail

isZipFile

Boolean isZipFile(String filename)

判断文件是否是zip格式

Parameters

  • filename 文件名

Returns

返回true代表文件是zip文件

open

ZipFile open(String path,String mod,Integer compress_type)

打开一个zip文件

Parameters

  • path 文件路径

  • mod 打开文件模式, “r”代表读取, “w”代表创建, “a”代表在zip文件后追加

  • compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。

Returns

返回zip文件对象

open

ZipFile open(Buffer data,String mod,Integer compress_type)

打开一个zip文件

Parameters

  • data zip文件数据

  • mod 打开文件模式, “r”代表读取, “w”代表创建, “a”代表在zip文件后追加

  • compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。

Returns

返回zip文件对象

open

ZipFile open(SeekableStream strm,String mod,Integer compress_type)

打开一个zip文件

Parameters

  • strm zip文件流

  • mod 打开文件模式, “r”代表读取, “w”代表创建, “a”代表在zip文件后追加

  • compress_type 压缩类型, ZIP_STORED 代表不压缩, 仅存储。 默认使用ZIP_DEFLATED 代表使用zlib库进行压缩。

Returns

返回zip文件对象