Cocos2d-x Lua 获取文件大小:io.open、seek 与错误处理 分类于 游戏开发 在 Cocos2d-x Lua 中通过 io.open 打开文件,使用 seek 定位末尾并返回字节数,最后关闭句柄;文件无法打开时返回 false。 返回指定文件的大小,如果失败返回 false 123456789101112131415-- @function [parent=#io] filesize-- @param string path 文件完全路径-- @return integer#integerfunction io.filesize(path) local size = false local file = io.open(path, "r") if file then local current = file:seek() size = file:seek("end") file:seek("set", current) io.close(file) end return sizeend 打赏 微信支付 支付宝 本文作者: 南锋 本文链接: https://lengmo714.top/6deadeef.html 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!