21 lines
473 B
Lua
21 lines
473 B
Lua
local files = {}
|
|
|
|
local open = io.open
|
|
|
|
function files.read_file(path)
|
|
local file = open(path, "rb") -- r read mode and b binary mode
|
|
if not file then return nil end
|
|
local content = file:read "*a" -- *a or *all reads the whole file
|
|
file:close()
|
|
return content
|
|
end
|
|
|
|
function files.write_file(path, content)
|
|
local file = open(path, "w")
|
|
if not file then return end
|
|
file:write(content)
|
|
file:flush()
|
|
return file:close()
|
|
end
|
|
|
|
return files |