统计文件行数 (LCC.web_file.line_count)
声明
count, err = LCC.web_file.line_count(path, timeout?)
参数
- path
字符串型,要统计的文件路径 - timeout
数值型,可选;请求超时时间(秒),默认60
返回值
- count
数值型,文本行数;失败时返回nil - err
字符串型或nil,失败时的错误描述
说明
获取文件行数,效率高于
get_lines后再计数。
支持大文件统计。
示例
local count, err = LCC.web_file.line_count("/日志/task.log")
if count then
print("日志行数:" .. count)
end