From 2d1c7a22f4e115ff2b6da213f2007c990e2bbc4c Mon Sep 17 00:00:00 2001 From: Timo Smit Date: Tue, 12 Feb 2019 18:06:29 +0100 Subject: [PATCH] Added files.exists function used in b2c357b03ff3e4fd42f8739f0eb0c453f5fe7f1f --- luascripts/wolfadmin/util/files.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/luascripts/wolfadmin/util/files.lua b/luascripts/wolfadmin/util/files.lua index f0533a2..577cf4f 100644 --- a/luascripts/wolfadmin/util/files.lua +++ b/luascripts/wolfadmin/util/files.lua @@ -36,6 +36,18 @@ function files.ls(directory) return entries end +function files.exists(fileName) + local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ) + + if fileLength ~= -1 then + et.trap_FS_FCloseFile(fileDescriptor) + + return true + end + + return false +end + function files.loadFromCFG(fileName, idExpr) local fileDescriptor, fileLength = et.trap_FS_FOpenFile(fileName, et.FS_READ)