gad*_*dss 12 size lua file coronasdk
我在使用Lua获取文件大小时遇到问题.我正在创建一个函数方法,如果文件的文件大小是743 bytes,那么该文件将被删除.
这是我的代码:
local getDLFile = function(fileToDL)
local path = system.pathForFile(fileToDL, system.DocumentsDirectory )
local myFile = io.open( path, "w+b" )
http.request{
url = "http://www.testfile.com/"..fileToDL,
sink = ltn12.sink.file(myFile),
}
-- i don't know what is the syntax
if myFile.size == 743 bytes then
myFile.delete
end
end
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决我的情况吗?
lhf*_*lhf 23
大小由myFile:seek("end").给出.
要删除该文件,请使用os.remove(path).但请先关闭文件.
最近Lua文件系统支持被添加到Corona!您可以使用获取文件大小
local lfs = require "lfs"
local size = lfs.attributes (path, "size")
Run Code Online (Sandbox Code Playgroud)
你可以在这里阅读 http://keplerproject.github.com/luafilesystem/manual.html#reference
删除文件使用
os.remove(path)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23390 次 |
| 最近记录: |