"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[8239],{6797:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>d,frontMatter:()=>s,metadata:()=>l,toc:()=>a});const l=JSON.parse('{"id":"XXTLanControl.lua/web-file/line_count","title":"Count Lines (LCC.web_file.line_count)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/line_count.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/line_count","permalink":"/docs/en/XXTLanControl.lua/web-file/line_count","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":150,"frontMatter":{"sidebar_position":150},"sidebar":"tutorialSidebar","previous":{"title":"Read File As Lines (LCC.web_file.get_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/get_lines"},"next":{"title":"Overwrite With Multiple Lines (LCC.web_file.set_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/set_lines"}}');var i=t(4848),r=t(8453);const s={sidebar_position:150},o="Count Lines (LCC.web_file.line_count)",c={},a=[{value:"Signature",id:"signature",level:2},{value:"Parameters",id:"parameters",level:2},{value:"Returns",id:"returns",level:2},{value:"Notes",id:"notes",level:2},{value:"Example",id:"example",level:2}];function u(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,r.R)(),...e.components};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"count-lines-lccweb_fileline_count",children:"Count Lines (LCC.web_file.line_count)"})}),"\n",(0,i.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-lua",children:"count, err = LCC.web_file.line_count(path, timeout?)\n"})}),"\n",(0,i.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["path",(0,i.jsx)(n.br,{}),"\n","String. File whose lines should be counted."]}),"\n",(0,i.jsxs)(n.li,{children:["timeout",(0,i.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,i.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,i.jsxs)(n.ul,{children:["\n",(0,i.jsxs)(n.li,{children:["count",(0,i.jsx)(n.br,{}),"\n","Number. Total lines; ",(0,i.jsx)(n.code,{children:"nil"})," on failure."]}),"\n",(0,i.jsxs)(n.li,{children:["err",(0,i.jsx)(n.br,{}),"\n","String or ",(0,i.jsx)(n.code,{children:"nil"}),". Error description when the call fails."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,i.jsxs)(n.blockquote,{children:["\n",(0,i.jsxs)(n.p,{children:["Returns the line count directly, faster than fetching the entire file.",(0,i.jsx)(n.br,{}),"\n","Works well for large files."]}),"\n"]}),"\n",(0,i.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,i.jsx)(n.pre,{children:(0,i.jsx)(n.code,{className:"language-lua",children:'local count, err = LCC.web_file.line_count("/logs/task.log")\nif count then\n    print("Log lines:" .. count)\nend\n'})})]})}function d(e={}){const{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(u,{...e})}):u(e)}},8453:(e,n,t)=>{t.d(n,{R:()=>s,x:()=>o});var l=t(6540);const i={},r=l.createContext(i);function s(e){const n=l.useContext(r);return l.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function o(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(i):e.components||i:s(e.components),l.createElement(r.Provider,{value:n},e.children)}}}]);