Replace A Single Line (LCC.web_file.set_line)
Signature
ok, old_line_or_err = LCC.web_file.set_line(path, line_number, line, timeout?)
Parameters
- path
String. File path. - line_number
Number. Line index to write; positive numbers start at1, negative values count from the end (-1is the last line), and0means after the last line. - line
String. New content. - timeout
Number, optional. Request timeout in seconds, default60.
Returns
- ok
Boolean.trueon success,falseon failure. - old_line_or_err
String ornil. Previous text when successful;nilwhen no existing line was replaced; error description when the call fails.
Notes
Wrapper around
set_range_linesfor single-line edits.
See the parameter description above for line-number rules.
Returns the previous text so you can compare or roll back.
Writing beyond the current content still creates a new line, withnilas the old value.
Example
local ok, old_line = LCC.web_file.set_line("/config/list.txt", 1, "Alpha")
if ok then
print("Old text: " .. (old_line or ""))
end