diff options
Diffstat (limited to 'src/ffluci/fs.lua')
-rw-r--r-- | src/ffluci/fs.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/ffluci/fs.lua b/src/ffluci/fs.lua index 5a1cc6b351..55da9b8dce 100644 --- a/src/ffluci/fs.lua +++ b/src/ffluci/fs.lua @@ -31,14 +31,36 @@ require("lfs") -- Returns the content of file function readfile(filename) local fp = io.open(filename) + if fp == nil then error("Unable to open file for reading: " .. filename) end + local data = fp:read("*a") fp:close() return data end +-- Returns the content of file as array of lines +function readfilel(filename) + local fp = io.open(filename) + local line = "" + local data = {} + + if fp == nil then + error("Unable to open file for reading: " .. filename) + end + + while true do + line = fp:read() + if (line == nil) then break end + table.insert(data, line) + end + + fp:close() + return data +end + -- Writes given data to a file function writefile(filename, data) local fp = io.open(filename, "w") |