fixed a few stupid bugs with shutil and fs
This commit is contained in:
parent
ba8a800940
commit
72e71c4c23
@ -77,6 +77,7 @@ do
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
function fs.list(s)
|
function fs.list(s)
|
||||||
|
s=s or ""
|
||||||
local _,d,p = fs.resolve(s)
|
local _,d,p = fs.resolve(s)
|
||||||
if not d then
|
if not d then
|
||||||
local kt = {}
|
local kt = {}
|
||||||
@ -104,3 +105,14 @@ do
|
|||||||
return fT[d].isDirectory(p)
|
return fT[d].isDirectory(p)
|
||||||
end
|
end
|
||||||
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
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
function cd(p)
|
cd=fs.cd
|
||||||
os.setenv("PWD",fs.simplify((os.getenv("PWD") or "").."/"..p))
|
rm=fs.rm
|
||||||
end
|
mkdir=fs.mkdir
|
||||||
function ls(p)
|
function ls(p)
|
||||||
for k,v in ipairs(fs.list(p)) do print(v) end
|
for k,v in ipairs(fs.list(p)) do print(v) end
|
||||||
end
|
end
|
||||||
function rm(p)
|
|
||||||
fs.rm(p)
|
|
||||||
end
|
|
||||||
function mkdir(p)
|
|
||||||
fs.mkdir(p)
|
|
||||||
end
|
|
||||||
|
Loading…
Reference in New Issue
Block a user