From 93c133813516b74af33dc58c776df90778a50321 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Sun, 10 Jul 2022 14:31:45 +0200 Subject: [PATCH] Add file.read_binary for consistency --- file.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/file.lua b/file.lua index bd912ea..a88598c 100644 --- a/file.lua +++ b/file.lua @@ -32,6 +32,14 @@ function read(filename) return content end +function read_binary(filename) + local file, err = io.open(filename, "rb") + if file == nil then return nil, err end + local content = file:read"*a" + file:close() + return content +end + function write_unsafe(filename, new_content) local file, err = io.open(filename, "w") if file == nil then return false, err end