From d3c46ace5f192201d369095145bf00b9f3c29435 Mon Sep 17 00:00:00 2001 From: v Date: Tue, 29 Dec 2020 09:45:24 +0000 Subject: [PATCH] Added current directory and rm to mfs --- mfs/lib/mfs.lua | 29 +++++++++++++++++++++++------ mfs/pkgmeta.ltn | 2 +- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/mfs/lib/mfs.lua b/mfs/lib/mfs.lua index f653101..33793bc 100644 --- a/mfs/lib/mfs.lua +++ b/mfs/lib/mfs.lua @@ -1,7 +1,20 @@ local mfs={} +local cd="" +function mfs.setcd(x) + if fs.exists(x) and fs.isDir(x) then + cd=x + return true + else + return false,"No such directory "..x + end +end + +function mfs.getcd() + return cd +end function mfs.read(x) - local f=fs.open(x,"r") + local f=fs.open(cd.."/"..x,"r") if not f then return nil end local i=f.readAll() f.close() @@ -9,23 +22,27 @@ function mfs.read(x) end function mfs.write(x,v) - local f=fs.open(x,"w") + local f=fs.open(cd.."/"..x,"w") f.write(v) f.close() end function mfs.mmkdir(x) - if not fs.exists(x) then - fs.makeDir(x) + if not fs.exists(cd.."/"..x) then + fs.makeDir(cd.."/"..x) end end function mfs.save(x,t) - mfs.write(x,textutils.serialize(t)) + mfs.write(cd.."/"..x,textutils.serialize(t)) end function mfs.load(x) - return textutils.unserialize(mfs.read(x) or "{}") + return textutils.unserialize(mfs.read(cd.."/"..x) or "{}") +end + +function mfs.rm(x) + fs.delete(cd.."/"..x) end return mfs diff --git a/mfs/pkgmeta.ltn b/mfs/pkgmeta.ltn index 2dfcdbf..25546b4 100644 --- a/mfs/pkgmeta.ltn +++ b/mfs/pkgmeta.ltn @@ -1,5 +1,5 @@ { - ["version"] = "0.1.2", + ["version"] = "0.1.3", ["dependencies"] = { },