Insert A Single Line (LCC.web_file.insert_line)
Signature
ok, err = LCC.web_file.insert_line(path, line_number, line, timeout?)
Parameters
- path
String. File path. - line_number
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. - line
String. Text to insert. - 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
Convenience wrapper around
insert_linesfor a single entry.
Inserts one line before the specified line index; see the parameter description above for line-number rules.
Useful for adding headers or log entries at specific spots.
Example
local ok, err = LCC.web_file.insert_line("/config/list.txt", 1, "Header")
if not ok then
error(err)
end