Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local io = require("io")
- local fs = require("filesystem")
- function ReadLine(Path, Line)
- local Cur = 0
- if (fs.exists(Path)) then
- for LINE in io.lines(Path) do
- Cur = Cur + 1
- if (Cur == Line) then
- return LINE
- end
- end
- end
- return nil
- end
- function WriteLine(Path, Line, Content)
- local Lines = {}
- if (fs.exists(Path)) then
- for LINE in io.lines(Path) do
- table.insert(Lines, LINE)
- end
- end
- table.remove(Lines, Line)
- table.insert(Lines, Line, Content)
- local File = fs.open(Path..".tmp", "w")
- for _, LINE in ipairs(Lines) do
- print("Writing: "..LINE)
- File:write(LINE.."\n")
- end
- File:close()
- if (fs.exists(Path)) then
- fs.remove(Path)
- end
- fs.rename(Path..".tmp", Path)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement