"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[8309],{2807:(e,n,i)=>{i.r(n),i.d(n,{assets:()=>c,contentTitle:()=>o,default:()=>u,frontMatter:()=>t,metadata:()=>l,toc:()=>d});const l=JSON.parse('{"id":"XXTLanControl.lua/web-file/insert_line","title":"\u63d2\u5165\u5355\u884c\u6587\u672c (LCC.web_file.insert_line)","description":"\u58f0\u660e","source":"@site/docs/XXTLanControl.lua/web-file/insert_line.md","sourceDirName":"XXTLanControl.lua/web-file","slug":"/XXTLanControl.lua/web-file/insert_line","permalink":"/docs/XXTLanControl.lua/web-file/insert_line","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":220,"frontMatter":{"sidebar_position":220},"sidebar":"tutorialSidebar","previous":{"title":"\u63d2\u5165\u591a\u884c\u6587\u672c (LCC.web_file.insert_lines)","permalink":"/docs/XXTLanControl.lua/web-file/insert_lines"},"next":{"title":"\u5220\u9664\u884c\u533a\u95f4 (LCC.web_file.remove_lines)","permalink":"/docs/XXTLanControl.lua/web-file/remove_lines"}}');var r=i(4848),s=i(8453);const t={sidebar_position:220},o="\u63d2\u5165\u5355\u884c\u6587\u672c (LCC.web_file.insert_line)",c={},d=[{value:"\u58f0\u660e",id:"\u58f0\u660e",level:2},{value:"\u53c2\u6570",id:"\u53c2\u6570",level:2},{value:"\u8fd4\u56de\u503c",id:"\u8fd4\u56de\u503c",level:2},{value:"\u8bf4\u660e",id:"\u8bf4\u660e",level:2},{value:"\u793a\u4f8b",id:"\u793a\u4f8b",level:2}];function a(e){const n={blockquote:"blockquote",br:"br",code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"\u63d2\u5165\u5355\u884c\u6587\u672c-lccweb_fileinsert_line",children:"\u63d2\u5165\u5355\u884c\u6587\u672c (LCC.web_file.insert_line)"})}),"\n",(0,r.jsx)(n.h2,{id:"\u58f0\u660e",children:"\u58f0\u660e"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:"ok, err = LCC.web_file.insert_line(path, line_number, line, timeout?)\n"})}),"\n",(0,r.jsx)(n.h2,{id:"\u53c2\u6570",children:"\u53c2\u6570"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["path",(0,r.jsx)(n.br,{}),"\n","\u5b57\u7b26\u4e32\u578b\uff0c\u76ee\u6807\u6587\u4ef6\u8def\u5f84"]}),"\n",(0,r.jsxs)(n.li,{children:["line_number",(0,r.jsx)(n.br,{}),"\n","\u6570\u503c\u578b\uff0c\u63d2\u5165\u57fa\u51c6\u884c\u53f7\uff1b\u6b63\u6570\u4ece ",(0,r.jsx)(n.code,{children:"1"})," \u8d77\u7b97\uff0c\u5728\u8be5\u884c\u524d\u63d2\u5165\uff1b\u8d1f\u6570\u4ece\u672b\u5c3e\u5012\u6570\uff0c",(0,r.jsx)(n.code,{children:"0"})," \u8868\u793a\u8ffd\u52a0\u5230\u672b\u5c3e\uff0c",(0,r.jsx)(n.code,{children:"-1"})," \u8868\u793a\u5728\u6700\u540e\u4e00\u884c\u524d"]}),"\n",(0,r.jsxs)(n.li,{children:["line",(0,r.jsx)(n.br,{}),"\n","\u5b57\u7b26\u4e32\u578b\uff0c\u63d2\u5165\u7684\u6587\u672c\u5185\u5bb9"]}),"\n",(0,r.jsxs)(n.li,{children:["timeout",(0,r.jsx)(n.br,{}),"\n","\u6570\u503c\u578b\uff0c\u53ef\u9009\uff1b\u8bf7\u6c42\u8d85\u65f6\u65f6\u95f4\uff08\u79d2\uff09\uff0c\u9ed8\u8ba4 ",(0,r.jsx)(n.code,{children:"60"})]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u8fd4\u56de\u503c",children:"\u8fd4\u56de\u503c"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["ok",(0,r.jsx)(n.br,{}),"\n","\u5e03\u5c14\u578b\uff0c\u6210\u529f\u63d2\u5165\u8fd4\u56de ",(0,r.jsx)(n.code,{children:"true"}),"\uff0c\u5931\u8d25\u8fd4\u56de ",(0,r.jsx)(n.code,{children:"false"})]}),"\n",(0,r.jsxs)(n.li,{children:["err",(0,r.jsx)(n.br,{}),"\n","\u5b57\u7b26\u4e32\u578b\u6216 ",(0,r.jsx)(n.code,{children:"nil"}),"\uff0c\u5931\u8d25\u65f6\u7684\u9519\u8bef\u63cf\u8ff0"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u8bf4\u660e",children:"\u8bf4\u660e"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsxs)(n.p,{children:["\u5728\u6307\u5b9a\u884c\u53f7\u524d\u63d2\u5165\u5355\u884c\u5185\u5bb9\u3002",(0,r.jsx)(n.br,{}),"\n","\u884c\u53f7\u89c4\u5219\u8be6\u89c1\u4e0a\u65b9\u53c2\u6570\u8bf4\u660e\u3002",(0,r.jsx)(n.br,{}),"\n","\u9002\u5408\u5728\u56fa\u5b9a\u6807\u9898\u540e\u63d2\u5165\u65b0\u914d\u7f6e\u6216\u65e5\u5fd7\u3002"]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"\u793a\u4f8b",children:"\u793a\u4f8b"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:'local ok, err = LCC.web_file.insert_line("/\u914d\u7f6e/list.txt", 1, "Header")\nif not ok then\n    error(err)\nend\n'})})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(a,{...e})}):a(e)}},8453:(e,n,i)=>{i.d(n,{R:()=>t,x:()=>o});var l=i(6540);const r={},s=l.createContext(r);function t(e){const n=l.useContext(s);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(r):e.components||r:t(e.components),l.createElement(s.Provider,{value:n},e.children)}}}]);