"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[6530],{8315:(e,n,r)=>{r.r(n),r.d(n,{assets:()=>a,contentTitle:()=>o,default:()=>u,frontMatter:()=>s,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"XXTLanControl.lua/web-file/writes","title":"Overwrite Controller File Content (LCC.web_file.writes)","description":"Signature","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/web-file/writes.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/writes","permalink":"/docs/en/XXTLanControl.lua/web-file/writes","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":100,"frontMatter":{"sidebar_position":100},"sidebar":"tutorialSidebar","previous":{"title":"Read Controller File Content (LCC.web_file.reads)","permalink":"/docs/en/XXTLanControl.lua/web-file/reads"},"next":{"title":"Append To Controller File (LCC.web_file.appends)","permalink":"/docs/en/XXTLanControl.lua/web-file/appends"}}');var i=r(4848),l=r(8453);const s={sidebar_position:100},o="Overwrite Controller File Content (LCC.web_file.writes)",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,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n.header,{children:(0,i.jsx)(n.h1,{id:"overwrite-controller-file-content-lccweb_filewrites",children:"Overwrite Controller File Content (LCC.web_file.writes)"})}),"\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:"ok, err = LCC.web_file.writes(path, data, 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. Destination file path."]}),"\n",(0,i.jsxs)(n.li,{children:["data",(0,i.jsx)(n.br,{}),"\n","String. Content to write."]}),"\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:["ok",(0,i.jsx)(n.br,{}),"\n","Boolean. ",(0,i.jsx)(n.code,{children:"true"})," when the write succeeds, ",(0,i.jsx)(n.code,{children:"false"})," otherwise."]}),"\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 operation 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:["Replaces the file contents completely.",(0,i.jsx)(n.br,{}),"\n","Missing parent directories and the file itself are created automatically.",(0,i.jsx)(n.br,{}),"\n","To write binary data, ensure the string carries the raw bytes."]}),"\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 ok, err = LCC.web_file.writes("/config/app.conf", "mode=auto\\n")\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,l.R)(),...e.components};return n?(0,i.jsx)(n,{...e,children:(0,i.jsx)(d,{...e})}):d(e)}},8453:(e,n,r)=>{r.d(n,{R:()=>s,x:()=>o});var t=r(6540);const i={},l=t.createContext(i);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(i):e.components||i:s(e.components),t.createElement(l.Provider,{value:n},e.children)}}}]);