刪除行區間 (LCC.web_file.remove_lines)
聲明
removed, err = LCC.web_file.remove_lines(path, start_line, count?, timeout?)
參數
- path
字串型,目標檔案路徑 - start_line
數值型,起始行號;正數從1起算,負數從末尾倒數(-1為最後一行),0表示末行之後 - count
數值型,可選;刪除行數,預設1 - timeout
數值型,可選;請求逾時時間(秒),預設60
回傳值
- removed
表格型,被刪除的行內容陣列;請求成功但沒有刪除到內容時傳回空表{},失敗時為nil - err
字串型或nil,失敗時的錯誤描述
說明
批次刪除指定範圍內的行。
行號規則詳見上方參數說明。
檔案不存在、超出範圍或count為0時傳回空表{}。
回傳值可用於日誌記錄或撤銷。
範例
local removed, err = LCC.web_file.remove_lines("/設定/list.txt", 2, 3)
if removed then
LCC.log(2, "刪除行", table.concat(removed, ","))
end