From f47674b9a7bacbd04ab70837033f32315d2058f7 Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 6 Oct 2022 07:44:59 +0200 Subject: [PATCH] Add mcl_util.file_exists() function --- mods/CORE/mcl_util/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mods/CORE/mcl_util/init.lua b/mods/CORE/mcl_util/init.lua index 9f68434ac..58285039a 100644 --- a/mods/CORE/mcl_util/init.lua +++ b/mods/CORE/mcl_util/init.lua @@ -22,6 +22,15 @@ function table.update_nil(t, ...) return t end +function mcl_util.file_exists(name) + local f = io.open(name) + if not f then + return false + end + f:close() + return true +end + -- Based on minetest.rotate_and_place --[[