Operating system for OpenComputers
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

19 lignes
496B

  1. 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
  2. if not (p:sub(1,1) == "/") then
  3. local np = {}
  4. for k,v in pairs(fs.segments(os.getenv("PWD").."/"..p)) do
  5. if v == ".." then
  6. np[#np] = nil
  7. else
  8. np[#np+1] = v
  9. end
  10. end
  11. p = "/"..table.concat(np,"/")
  12. end
  13. if fs.list(p) then
  14. os.setenv("PWD",p)
  15. else
  16. return false, "no such directory"
  17. end
  18. end