Add modlib.file.write_binary

This commit is contained in:
Lars Mueller 2021-12-28 00:04:58 +01:00
parent a89ce5bca8
commit a243d2ae48

@ -42,6 +42,14 @@ end
write = minetest and minetest.safe_file_write or write_unsafe
function write_binary(filename, new_content)
local file = io.open(filename, "wb")
if file == nil then return false end
file:write(new_content)
file:close()
return true
end
function ensure_content(filename, ensured_content)
local content = read(filename)
if content ~= ensured_content then