📝 docs(tsl): rebuild canonical syntax and routing manual
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
#### 压缩和解压函数
|
||||
|
||||
##### 内容
|
||||
|
||||
- 压缩和解压函数简介
|
||||
- ZipCompress
|
||||
- ZipExtract
|
||||
- RarExtract
|
||||
- 压缩解压函数使用说明
|
||||
- unicompress
|
||||
- uniuncompress
|
||||
|
||||
##### 压缩和解压函数简介
|
||||
|
||||
ZIP和RAR是最常见的文件压缩格式,为此天软提供了ZIP文件压缩和解压函数,以及RAR的解压支持。因RAR格式版权所有人不允许除自己外的第二者提供压缩支持,目前天软没有提供RAR的压缩函数。
|
||||
|
||||
##### ZipCompress
|
||||
|
||||
范例
|
||||
|
||||
```tsl
|
||||
// 把文件d:\a.txt压缩到d:\a.zip文件中的/hello/world/a.txt中
|
||||
ZipCompress('', 'd:\\a.zip', '', 'd:\\a.txt', 'hello/world/a.txt');
|
||||
// 将d:\tmp目录压缩到d:\a.zip文件中
|
||||
ZipCompress('', 'd:\\a.zip', '', 'd:\\tmp', 'test');
|
||||
```
|
||||
|
||||
##### ZipExtract
|
||||
|
||||
范例
|
||||
|
||||
```tsl
|
||||
// 将ZIP文件解压,可以使用ZipExtract函数,例如将d:\a.zip文件解压到d:\tmp目录
|
||||
ZipExtract('', 'd:\\a.zip', '', 'd:\\tmp', '123');
|
||||
```
|
||||
|
||||
##### RarExtract
|
||||
|
||||
范例
|
||||
|
||||
```tsl
|
||||
// 将RAR文件解压,可以使用RarExtract函数,例如将d:\a.rar文件解压到d:\tmp目录
|
||||
RarExtract('', 'd:\\a.rar', '', 'd:\\tmp', '123');
|
||||
```
|
||||
|
||||
##### 压缩解压函数使用说明
|
||||
|
||||
函数中的alias参数用于指定目录别名
|
||||
|
||||
ZipCompress函数可以将由filename指定的文件或目录压缩到由zip_filename指定的压缩文件中,如果压缩文件不存在,函数会创建一个。ZIP格式的压缩不支持加密。
|
||||
|
||||
函数中所指定的path是压缩文件或目录在ZIP文件中的路径。如同文件系统中文件是在树状的目录结构中存储一样,ZIP文件中所存储的文件也是树状结构的,通过指定path参数,我们可以将文件或目录压缩后存放到ZIP文件中指定的目录下,如果path参数为空(“”),就压缩到ZIP的根目录下。例如我们把文件d:\a.txt压缩到d:\a.zip文件中的/hello/world/a.txt中,可以使用下面的语句:
|
||||
|
||||
```tsl
|
||||
ZipCompress('', 'd:\\a.zip', '', 'd:\\a.txt', 'hello/world/a.txt');
|
||||
```
|
||||
|
||||
又如我们要将d:\tmp目录压缩到d:\a.zip文件中的根下,可以使用这样的语句:
|
||||
|
||||
```tsl
|
||||
ZipCompress('', 'd:\\a.zip', '', 'd:\\tmp', 'test');
|
||||
```
|
||||
|
||||
要将ZIP文件解压,可以使用ZipExtract函数,例如将d:\a.zip文件解压到d:\tmp目录:
|
||||
|
||||
```tsl
|
||||
ZipExtract('', 'd:\\a.zip', '', 'd:\\tmp', '123') ;
|
||||
```
|
||||
|
||||
要将RAR文件解压,可以使用RarExtract函数,例如将d:\a.rar文件解压到d:\tmp目录:
|
||||
|
||||
```tsl
|
||||
RarExtract('', 'd:\\a.rar', '', 'd:\\tmp', '123');
|
||||
```
|
||||
|
||||
##### unicompress
|
||||
|
||||
范例
|
||||
|
||||
本地运行下面脚本:
|
||||
|
||||
```tsl
|
||||
data := "Holle Tinysoft天软";
|
||||
s := unicompress("zstd", data);
|
||||
echo s, "\r\n";
|
||||
echo uniuncompress("zstd", s), "\r\n";
|
||||
return 1;
|
||||
```
|
||||
|
||||
##### uniuncompress
|
||||
|
||||
范例
|
||||
|
||||
```tsl
|
||||
data := "Holle Tinysoft天软";
|
||||
len := length(data);
|
||||
s := unicompress("zstd", data);
|
||||
echo s, "\r\n";
|
||||
echo uniuncompress("zstd", s, len), "\r\n";
|
||||
return 1;
|
||||
```
|
||||
Reference in New Issue
Block a user