"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[5099],{8453:(e,n,i)=>{i.d(n,{R:()=>s,x:()=>o});var t=i(6540);const r={},l=t.createContext(r);function s(e){const n=t.useContext(l);return t.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(r):e.components||r:s(e.components),t.createElement(l.Provider,{value:n},e.children)}},9975:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>s,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"XXTLanControl.lua/web-file/set_lines","title":"Overwrite With Multiple Lines (LCC.web_file.set_lines)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/set_lines.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/set_lines","permalink":"/docs/en/XXTLanControl.lua/web-file/set_lines","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":160,"frontMatter":{"sidebar_position":160},"sidebar":"tutorialSidebar","previous":{"title":"Count Lines (LCC.web_file.line_count)","permalink":"/docs/en/XXTLanControl.lua/web-file/line_count"},"next":{"title":"Read A Range Of Lines (LCC.web_file.get_range_lines)","permalink":"/docs/en/XXTLanControl.lua/web-file/get_range_lines"}}');var r=i(4848),l=i(8453);const s={sidebar_position:160},o="Overwrite With Multiple Lines (LCC.web_file.set_lines)",a={},c=[{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 d(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,l.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"overwrite-with-multiple-lines-lccweb_fileset_lines",children:"Overwrite With Multiple Lines (LCC.web_file.set_lines)"})}),"\n",(0,r.jsx)(n.h2,{id:"signature",children:"Signature"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.web_file.set_lines(path, lines, timeout?)\n"})}),"\n",(0,r.jsx)(n.h2,{id:"parameters",children:"Parameters"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["path",(0,r.jsx)(n.br,{}),"\n","String. File to write."]}),"\n",(0,r.jsxs)(n.li,{children:["lines",(0,r.jsx)(n.br,{}),"\n","Table. Ordered array of strings."]}),"\n",(0,r.jsxs)(n.li,{children:["timeout",(0,r.jsx)(n.br,{}),"\n","Number, optional. Request timeout in seconds, default ",(0,r.jsx)(n.code,{children:"60"}),"."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"returns",children:"Returns"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["ok",(0,r.jsx)(n.br,{}),"\n","Boolean. ",(0,r.jsx)(n.code,{children:"true"})," on success, ",(0,r.jsx)(n.code,{children:"false"})," on failure."]}),"\n",(0,r.jsxs)(n.li,{children:["err",(0,r.jsx)(n.br,{}),"\n","String or ",(0,r.jsx)(n.code,{children:"nil"}),". Error description when the write fails."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"notes",children:"Notes"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["Joins the lines and replaces the entire file.",(0,r.jsx)(n.br,{}),"\n","Missing parent directories and the file itself are created automatically.",(0,r.jsx)(n.br,{}),"\n","Ideal for rebuilding configuration or template files."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"example",children:"Example"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.web_file.set_lines("/config/list.txt", {"A", "B", "C"})\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]);