Jump to content




Dir Functions, Need Some Help With My Derp


  • You cannot reply to this topic
3 replies to this topic

#1 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 27 August 2013 - 01: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?

#2 McLeopold

  • Members
  • 123 posts

Posted 27 August 2013 - 02: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.

#3 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 27 August 2013 - 02:25 PM

Or just use:
shell.resolve("SomeOtherDir")
That should return the same as:
fs.combine(shell.dir(), "SomeOtherDir")


#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 27 August 2013 - 04: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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users