Insert Multiple Lines (LCC.web_file.insert_lines)
Signature
ok, err = LCC.web_file.insert_lines(path, start_line, lines, timeout?)
Parameters
- path
String. File path. - start_line
Number. Reference line index for insertion. Positive numbers start at1and insert before that line; negative values count from the end,0appends after the last line, and-1inserts before the last line. - lines
Table. Array of line strings to insert in order. - timeout
Number, optional. Request timeout in seconds, default60.
Returns
- ok
Boolean.trueon success,falseon failure. - err
String ornil. Error description when the operation fails.
Notes
Inserts lines before the specified line index; see the parameter description above for line-number rules.
When the target position is beyond the current end, blank lines are padded automatically.
Newline structure is automatically preserved for the inserted content.
Example
local ok, err = LCC.web_file.insert_lines("/config/list.txt", 2, {"New 1", "New 2"})
if not ok then
error(err)
end