mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 16:53:46 +01:00
Add file.ensure_content
This commit is contained in:
parent
2e4f03c94e
commit
f4ee51e543
8
file.lua
8
file.lua
@ -14,6 +14,14 @@ function write(filename, new_content)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ensure_content(filename, ensured_content)
|
||||||
|
local content = read(filename)
|
||||||
|
if content ~= ensured_content then
|
||||||
|
return write(filename, ensured_content)
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function append(filename, new_content)
|
function append(filename, new_content)
|
||||||
local file = io.open(filename, "a")
|
local file = io.open(filename, "a")
|
||||||
if file == nil then return false end
|
if file == nil then return false end
|
||||||
|
Loading…
Reference in New Issue
Block a user