获得文件长度
复制代码 代码如下:
function length_of_file(filename)
local fh = assert(io.open(filename, "rb"))
local len = assert(fh:seek("end"))
fh:close()
return len
end
判断文件是否存在
复制代码 代码如下:
function file_exists(path)
local file = io.open(path, "rb")
if file then file:close() end
return file ~= nil
end
最后
以上就是犹豫白昼最近收集整理的关于Lua获取文件长度和判断文件是否存在函数分享的全部内容,更多相关Lua获取文件长度和判断文件是否存在函数分享内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复