瀏覽代碼

add zip files examples (#97)

star9029 3 年之前
父節點
當前提交
0342df6d3b
共有 2 個文件被更改,包括 54 次插入6 次删除
  1. 27 3
      manual/extension_modules.md
  2. 27 3
      zh-cn/manual/extension_modules.md

+ 27 - 3
manual/extension_modules.md

@@ -1575,14 +1575,38 @@ local branches = git.branches(url)
 
 ### utils.archive
 
-This module is used to compress and decompress files.
+This module is used to compress and decompress files. It supports decompression of most common compression formats. It will automatically detect which compression tools are provided by the system, and then will use the most appropriate compression tool for the operation.
+
+#### archive.archive
+
+- zip files
+
+```lua
+import("utils.archive")
+
+archive.archive("/tmp/outputdir", "/tmp/a.zip")
+archive.archive("/tmp/outputdir", "/tmp/a.7z")
+archive.archive("/tmp/outputdir", "/tmp/a.gzip")
+archive.archive("/tmp/outputdir", "/tmp/a.tar.bz2")
+```
+
+Some configuration options can also be added, such as recursive directories, compression quality, exclude files, etc.
+
+```lua
+import("utils.archive")
+
+local options = {}
+options.curdir = "/tmp"
+options.recurse = true
+options.compress = "fastest|faster|default|better|best"
+options.excludes = {"*/dir/*", "dir/*"}
+archive.archive("/tmp/outputdir", "/tmp/a.zip", options)
+```
 
 #### archive.extract
 
 - unzip files
 
-Supports the decompression of most commonly used compressed files. It automatically detects which decompression tools are provided by the system, and then adapts them to the most suitable decompressor to decompress the specified compressed files.
-
 ```lua
 import("utils.archive")
 

+ 27 - 3
zh-cn/manual/extension_modules.md

@@ -1556,14 +1556,38 @@ local branches = git.branches(url)
 
 ### utils.archive
 
-此模块用于压缩和解压缩文件。
+此模块用于压缩和解压文件。支持大部分常用压缩格式的解压缩,它会自动检测系统提供了哪些压缩工具,然后会使用最合适的压缩工具进行操作。
+
+#### archive.archive
+
+- 压缩文件
+
+```lua
+import("utils.archive")
+
+archive.archive("/tmp/outputdir", "/tmp/a.zip")
+archive.archive("/tmp/outputdir", "/tmp/a.7z")
+archive.archive("/tmp/outputdir", "/tmp/a.gzip")
+archive.archive("/tmp/outputdir", "/tmp/a.tar.bz2")
+```
+
+还可以添加一些配置选项,如递归目录,压缩质量,排除文件等。
+
+```lua
+import("utils.archive")
+
+local options = {}
+options.curdir = "/tmp"
+options.recurse = true
+options.compress = "fastest|faster|default|better|best"
+options.excludes = {"*/dir/*", "dir/*"}
+archive.archive("/tmp/outputdir", "/tmp/a.zip", options)
+```
 
 #### archive.extract
 
 - 解压文件
 
-支持大部分常用压缩文件的解压,它会自动检测系统提供了哪些解压工具,然后适配到最合适的解压器对指定压缩文件进行解压操作。
-
 ```lua
 import("utils.archive")