A5下载文章资讯

分类分类

Lua获取文件长度和判断文件是否存在函数分享

2015-04-20 14:15作者:zhao

获得文件长度

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

展开全部

相关

说两句网友评论
    我要跟贴
    取消