From b06887f2d97d766a202b8e74cad8ed249e305a3d Mon Sep 17 00:00:00 2001 From: Izaya Date: Sun, 23 Apr 2017 11:03:43 +1000 Subject: [PATCH] Wrote an extended fs library Should be pretty usable now. Mostly completes #3 --- modules.cfg | 1 + modules/library/fs-ext.lua | 12 ++++++++++++ modules/library/fs-min.lua | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 modules/library/fs-ext.lua diff --git a/modules.cfg b/modules.cfg index db0eff6..d5f6ac5 100644 --- a/modules.cfg +++ b/modules.cfg @@ -5,6 +5,7 @@ drivers/keyboard.lua library/net.lua library/fs-min.lua library/fs-std.lua +library/fs-ext.lua util/fs-automount.lua applications/shutil.lua applications/luash.lua diff --git a/modules/library/fs-ext.lua b/modules/library/fs-ext.lua new file mode 100644 index 0000000..bd300c1 --- /dev/null +++ b/modules/library/fs-ext.lua @@ -0,0 +1,12 @@ +function flist(s) + local d,p = fres(s) + return d.list(p or "/") +end +function fmkdir(s) + local d,p = fres(s) + return d.makeDirectory(p or "/") +end +function frm(s) + local d,p = fres(s) + return d.remove(p) +end diff --git a/modules/library/fs-min.lua b/modules/library/fs-min.lua index f717d35..140194d 100644 --- a/modules/library/fs-min.lua +++ b/modules/library/fs-min.lua @@ -1,6 +1,6 @@ fT = {} function fres(p) - local fid = (p:match("(%a-):.+") or p:match("/?(%a-)/.+")) + local fid = (p:match("(%a-):") or p:match("/?(%a-)/")) local pt = (p:match("%a-:(.+)") or p:match("/?%a-/(.+)")) - if fT[fid] ~= nil and pt ~= nil then return fT[fid],pt else return false end + if fT[fid] ~= nil then return fT[fid],pt else return false end end