archive

archive

archive模块实现文档的压缩和解压

zip

名称类型参数返回值说明
compress方法files:[]string,outFile:stringboolean压缩文件和文件夹
decompress方法file:string,outPath:stringboolean解压缩

compress

zip 压缩文件和文件夹

语法

zip.compress(files:[]string,outFile:string)

参数

  • files:[]string 要压缩的文件或文件夹路径
  • outFile:string 压缩后的文件路径

示例

import {zip} from "archive"
//将目录1和file.txt压缩成out.zip
zip.compress(["/Users/xx/目录1","/Users/xx/file.txt"],"/Users/xx/out.zip")

decompress

解压zip文件

语法

zip.decompress(file:string,outPath:string)

参数

  • file:string 要解压的zip文件
  • outPath:string 压缩后文件存储的目录

示例

import {zip} from "archive"
//将out.zip解压到目录out/
zip.decompress("/Users/xx/out.zip","/Users/xx/out/")

tar

名称类型参数返回值说明
compress方法files:[]string,outFile:stringboolean压缩文件和文件夹
decompress方法file:string,outPath:stringboolean解压缩

compress

tar 压缩文件和文件夹

语法

tar.compress(files:[]string,outFile:string)

参数

  • files:[]string 要压缩的文件或文件夹路径
  • outFile:string 压缩后的文件路径

示例

import {tar} from "archive"
//将目录1和file.txt压缩成out.tar
tar.compress(["/Users/xx/目录1","/Users/xx/file.txt"],"/Users/xx/out.tar")

decompress

解压tar文件

语法

tar.decompress(file:string,outPath:string)

参数

  • file:string 要解压的tar文件
  • outPath:string 压缩后文件存储的目录

示例

import {tar} from "archive"
//将out.tar解压到目录out/
tar.decompress("/Users/xx/out.tar","/Users/xx/out/")

gzip

名称类型参数返回值说明
compress方法file:string,outFile:stringboolean压缩文件
decompress方法file:string,outPath:stringboolean解压缩

compress

gzip 压缩文件

语法

gzip.compress(file:string,outFile:string)

参数

  • file:string 要压缩的文件
  • outFile:string 压缩后的文件路径

示例

import {gzip} from "archive"
//将out.tar文件压缩成out.tar.gz
gzip.compress("/Users/xx/out.tar","/Users/xx/out.tar.gz")

decompress

解压gzip文件

语法

gzip.decompress(file:string,outPath:string)

参数

  • file:string 要解压的gzip文件
  • outPath:string 压缩后文件存储的目录

示例

import {gzip} from "archive"
//将out.tar.gz解压到out.tar
gzip.decompress("/Users/xx/out.tar.gz","/Users/xx/out.tar")

案例

import {gzip,tar} from "archive"
//压缩成tar
tar.compress(["/Users/xx/目录1","/Users/xx/file.txt"],"/Users/xx/out.tar")
//压缩成tar.gz
gzip.compress("/Users/xx/out.tar","/Users/xx/out.tar.gz")
//解压缩tar.gz
gzip.decompress("/Users/xx/out.tar.gz","/Users/xx/out1.tar")
//解压缩tar
tar.decompress("/Users/xx/out1.tar","/Users/xx/out/")
更新时间 8/16/2024, 3:17:38 PM