統計檔案行數 (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