playbook/docs/tsl/reference/catalog/compression.md

85 lines
4.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 压缩和解压函数
文档类型:函数事实页
是否可直接用于生成代码:是;本页函数条目均包含参数表
遇到不确定时:回到 [../index.md](../index.md)、[../../syntax/index.md](../../syntax/index.md)
这一页描述压缩、解压与归档能力。生成函数调用时,只按函数条目中的参数表传参。
## 模块范围
- 说明:压缩、解压与归档能力
- 函数事实数5
## 函数事实
### `zipCompress(zip_alias, zip_filename, file_alias, filename, path)`
用途:函数事实相关函数。
参数个数5
返回值:处理结果
| 参数位置 | 参数名 | 必填 | 接收类型 | 说明 |
| -------- | -------------- | ---- | -------- | ---------------------------------------------------- |
| 1 | `zip_alias` | 是 | 字符串 | ZIP 文件所在目录别名;不用别名时传空字符串 |
| 2 | `zip_filename` | 是 | 字符串 | ZIP 文件路径;不存在时会创建 |
| 3 | `file_alias` | 是 | 字符串 | 被压缩文件或目录的目录别名;不用别名时传空字符串 |
| 4 | `filename` | 是 | 字符串 | 要压缩的文件或目录路径 |
| 5 | `path` | 是 | 字符串 | 压缩后在 ZIP 内部保存的路径;空字符串表示 ZIP 根目录 |
### `zipExtract(zip_alias, zip_filename, output_alias, output_dir[, password])`
用途:函数事实相关函数。
参数个数4 到 5
返回值:处理结果
| 参数位置 | 参数名 | 必填 | 接收类型 | 说明 |
| -------- | -------------- | ---- | -------- | ------------------------------------------ |
| 1 | `zip_alias` | 是 | 字符串 | ZIP 文件所在目录别名;不用别名时传空字符串 |
| 2 | `zip_filename` | 是 | 字符串 | ZIP 文件路径 |
| 3 | `output_alias` | 是 | 字符串 | 解压目标目录别名;不用别名时传空字符串 |
| 4 | `output_dir` | 是 | 字符串 | 解压目标目录 |
| 5 | `password` | 否 | 字符串 | ZIP 密码;普通 ZIP 可省略或传空字符串 |
### `rarExtract(rar_alias, rar_filename, alias, path[, password])`
用途:将 RAR 文件解压到指定目录。
参数个数4 到 5
返回值是否成功1/0
| 参数位置 | 参数名 | 必填 | 接收类型 | 说明 |
| -------- | -------------- | ---- | -------- | ------------------------------------------ |
| 1 | `rar_alias` | 是 | 字符串 | RAR 文件所在目录别名;不用别名时传空字符串 |
| 2 | `rar_filename` | 是 | 字符串 | RAR 文件名称或路径 |
| 3 | `alias` | 是 | 字符串 | 文件解压目录别名;不用别名时传空字符串 |
| 4 | `path` | 是 | 字符串 | 文件解压路径 |
| 5 | `password` | 否 | 字符串 | RAR 加密密码;普通 RAR 可省略 |
### `unicompress(method, data)`
用途:函数事实相关函数。
参数个数2
返回值:处理结果
| 参数位置 | 参数名 | 必填 | 接收类型 | 说明 |
| -------- | -------- | ---- | -------- | --------------------------------- |
| 1 | `method` | 是 | 字符串 | 压缩算法名;源文档示例使用 `zstd` |
| 2 | `data` | 是 | 字符串 | 要压缩的数据 |
### `uniuncompress(method, data[, length])`
用途:函数事实相关函数。
参数个数2 到 3
返回值:处理结果
| 参数位置 | 参数名 | 必填 | 接收类型 | 说明 |
| -------- | -------- | ---- | ---------- | ------------------------------------------------------ |
| 1 | `method` | 是 | 字符串 | 解压算法名;源文档示例使用 `zstd` |
| 2 | `data` | 是 | 二进制数据 | `unicompress` 返回的压缩数据 |
| 3 | `length` | 否 | 整数 | 原始数据长度;省略时也可解压源文档示例中的 `zstd` 数据 |