diff --git a/modules/lib/fs.lua b/modules/lib/fs.lua index 6877cd7..0e6f100 100644 --- a/modules/lib/fs.lua +++ b/modules/lib/fs.lua @@ -27,11 +27,17 @@ do p=(os.getenv("PWD") or "").."/"..p end p=fs.simplify(p) - local pt = {} + local pt,spt = {},"" for P in p:gmatch("[^/]+") do pt[#pt+1] = P end - return pt, p:match("/?(.-)/"), p:match("/?.-/(.+)") + for i = 2, #pt do + spt=spt..pt[i] + end + return pt, pt[1], spt + end + function fs.exec(fc,m,...) + return fT[fc][m](...) end function fs.open(p,m) local _,d,p = fs.resolve(p) @@ -70,8 +76,15 @@ do end return false end - function fs.list(s) + function fs.list(s) local _,d,p = fs.resolve(s) + if not d then + local kt = {} + for k,v in pairs(fT) do + kt[#kt+1] = k + end + return kt + end return fT[d].list(p or "/") end function fs.mkdir(s) @@ -79,15 +92,15 @@ do return fT[d].makeDirectory(p or "/") end function fs.rm(s) - local d,p = fs.resolve(s) + local _,d,p = fs.resolve(s) return fT[d].remove(p) end function fs.exists(s) - local d,p = fs.resolve(s) + local _,d,p = fs.resolve(s) return fT[d].exists(p) end function fs.isdir(s) - local d,p = fs.resolve(s) + local _,d,p = fs.resolve(s) return fT[d].isDirectory(p) end end