From e341ada43ef42de69ed71f30f0d3f1a38307232b Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Fri, 4 Aug 2017 17:44:10 +1000 Subject: [PATCH] fixed a few crashes resulting from the fs library --- modules/lib/fs.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/modules/lib/fs.lua b/modules/lib/fs.lua index bfca5b4..3278dfc 100644 --- a/modules/lib/fs.lua +++ b/modules/lib/fs.lua @@ -42,13 +42,15 @@ do function fs.open(p,m) local _,d,p = fs.resolve(p) local d = fT[d] - local f,C=d.open(p,m),hT._c - if f then - hT._c = C + 1 - hT[C] = {d,f} - return C + if d then + local f,C=d.open(p,m),hT._c + if f then + hT._c = C + 1 + hT[C] = {d,f} + return C + end + return false end - return false end function fs.close(h) if hT[h] then @@ -99,7 +101,9 @@ do end function fs.exists(s) local _,d,p = fs.resolve(s) - return fT[d].exists(p) + if d then + return fT[d].exists(p) + end end function fs.isdir(s) local _,d,p = fs.resolve(s)