From 6df2bcf1f1dba3e4b5529f524e0893e1c0b2010d Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 30 Mar 2021 22:26:30 +0200 Subject: [PATCH] Use minetest.safe_file_write --- file.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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