fixed a few stupid bugs with shutil and fs

This commit is contained in:
Izaya 2017-08-01 16:29:56 +10:00
parent ba8a800940
commit 72e71c4c23
2 changed files with 15 additions and 9 deletions

View File

@ -77,6 +77,7 @@ do
return false
end
function fs.list(s)
s=s or ""
local _,d,p = fs.resolve(s)
if not d then
local kt = {}
@ -104,3 +105,14 @@ do
return fT[d].isDirectory(p)
end
end
function fs.cd(p)
if p:sub(1,1) ~= "/" then
p=(os.getenv("PWD") or "").."/"..p
end
p=fs.simplify(p)
if fs.exists(p) and fs.isdir(p) then
os.setenv("PWD",p)
else
error("non-existent/not a dir")
end
end

View File

@ -1,12 +1,6 @@
function cd(p)
os.setenv("PWD",fs.simplify((os.getenv("PWD") or "").."/"..p))
end
cd=fs.cd
rm=fs.rm
mkdir=fs.mkdir
function ls(p)
for k,v in ipairs(fs.list(p)) do print(v) end
end
function rm(p)
fs.rm(p)
end
function mkdir(p)
fs.mkdir(p)
end