函数:ts.zip 文件压缩(仅支持 iOS)

函数名称:文件压缩 函数功能:文件压缩,生成压缩包

支持版本:仅 ts.so v1.2.1 以上版本支持

函数方法

local fileList = { {path1,bakpath1}, {path2,bakpath2}, {path3,bakpath3}, ... } flag = ts.zip(zipPath,fileList)

参数 类型 必填 说明
path string 压缩前文件路径,仅支持文件不支持目录
bakpath string 压缩包内文件路径,支持新建子目录
zipPath string 压缩包生成路径
fileList table 文件路径列表,仅支持文件不支持目录
返回值 类型 说明
flag boolean 成功返回 true,失败返回 false

函数用例

local ts = require("ts")
local root = userPath()
io.open(root .. "/res/1.txt","w"):write("测试"):close()
io.open(root .. "/res/2.txt","w"):write("测试"):close()
io.open(root .. "/res/3.txt","w"):write("还是测试"):close()
local fileList = {
    {root .. "/res/1.txt","1.txt"},
    {root .. "/res/2.txt","/file/2.txt"},
    {root .. "/res/3.txt","3.txt"}
}
flag = ts.zip(root .. "/res/测试.zip",fileList)
if flag then
dialog("压缩成功", time)
else
dialog("压缩失败", time)
end

注意事项

  • 添加到压缩包的文件名是中文的情况下会导致文件名乱码,请使用英文文件名
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""