This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheOddByte's profile picture

Dir Functions, Need Some Help With My Derp

Started by TheOddByte, 27 August 2013 - 12:25 PM
TheOddByte #1
Posted 27 August 2013 - 02:25 PM
Hello, I've bumped into a problem I hope to get solved..
It doesn't give me an error code or anything but I just wanted to know how this works..

local rDir = shell.dir() --This is the default folder
shell.setDir("SomeDir") -- Sets it to the dir I want
if fs.isDir(shell.resolve(".").."SomeOtherDir") then print("It was a dir!") end -- Checks if the dir inside the dir is a dir(Wow.. That was alot of dir)
NOTE: This isn't the exact code I'm using, Just a similiar to it

So the problem is that "SomeOtherDir" is a folder and it doesn't print that.. I have tested using shell.dir() also.
So how would I check if the dir inside a dir is a dir?
McLeopold #2
Posted 27 August 2013 - 03:03 PM
shell.resolve(".") should return "SomeDir" and you concatenated that with "SomeOtherDir" to make "SomeDirSomeOtherDir".

Use fs.combine(shell.resolve("."), "SomeOtherDir") to make "SomeDir/SomeOtherDir" and then it should work.
MysticT #3
Posted 27 August 2013 - 03:25 PM
Or just use:

shell.resolve("SomeOtherDir")
That should return the same as:

fs.combine(shell.dir(), "SomeOtherDir")
TheOddByte #4
Posted 27 August 2013 - 05:03 PM
Thanks to you both, I wasn't really sure of how shell.resolve worked exactly.. But it works now, And I'll probably use shell.resolve. But both was helpful.