파일의 행 수 집계 (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