mirror of
https://git.shadowkat.net/izaya/OC-PsychOS2.git
synced 2024-11-22 03:54:20 -05:00
19 lines
496 B
Lua
19 lines
496 B
Lua
function os.chdir(p) -- string -- boolean string -- changes the current working directory of the calling process to the directory specified in *p*, returning true or false, error
|
|
if not (p:sub(1,1) == "/") then
|
|
local np = {}
|
|
for k,v in pairs(fs.segments(os.getenv("PWD").."/"..p)) do
|
|
if v == ".." then
|
|
np[#np] = nil
|
|
else
|
|
np[#np+1] = v
|
|
end
|
|
end
|
|
p = "/"..table.concat(np,"/")
|
|
end
|
|
if fs.list(p) then
|
|
os.setenv("PWD",p)
|
|
else
|
|
return false, "no such directory"
|
|
end
|
|
end
|