packages1/mfs/lib/mfs.lua

32 lines
440 B
Lua
Raw Normal View History

2020-12-28 09:57:39 +00:00
local mfs={}
function mfs.read(x)
local f=fs.open(x,"r")
if not f then return nil end
local i=f.readAll()
f.close()
return i
end
function mfs.write(x,v)
local f=fs.open(x,"w")
f.write(v)
f.close()
end
function mfs.mmkdir(x)
if not fs.exists(x) then
fs.makeDir(x)
end
end
2020-12-28 13:16:19 +00:00
function mfs.save(x,t)
mfs.write(x,textutils.serialize(t))
end
function mfs.load(x)
return textutils.unserialize(mfs.read(x) or "{}")
end
2020-12-28 10:03:22 +00:00
return mfs