diff --git a/file.lua b/file.lua index c80fa64..3ed5dbf 100644 --- a/file.lua +++ b/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