mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-29 10:43:43 +01:00
Use minetest.safe_file_write
This commit is contained in:
parent
cd1c99c1db
commit
6df2bcf1f1
4
file.lua
4
file.lua
@ -6,7 +6,7 @@ function read(filename)
|
||||
return content
|
||||
end
|
||||
|
||||
function write(filename, new_content)
|
||||
function write_unsafe(filename, new_content)
|
||||
local file = io.open(filename, "w")
|
||||
if file == nil then return false end
|
||||
file:write(new_content)
|
||||
@ -14,6 +14,8 @@ function write(filename, new_content)
|
||||
return true
|
||||
end
|
||||
|
||||
write = minetest and minetest.safe_file_write or write_unsafe
|
||||
|
||||
function ensure_content(filename, ensured_content)
|
||||
local content = read(filename)
|
||||
if content ~= ensured_content then
|
||||
|
Loading…
Reference in New Issue
Block a user