跳到主要内容

统计文件行数 (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