From a243d2ae489d7a63b3209edc231ea9731abb7d04 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 28 Dec 2021 00:04:58 +0100 Subject: [PATCH] Add modlib.file.write_binary --- file.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/file.lua b/file.lua index 73d7aa4..316a2f4 100644 --- a/file.lua +++ b/file.lua @@ -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