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

shell.resolve() What does it?

Started by H4X0RZ, 09 May 2013 - 06:42 PM
H4X0RZ #1
Posted 09 May 2013 - 08:42 PM
Question in the title …
DiamondQ #2
Posted 09 May 2013 - 09:09 PM
It resolves a relative path into an absolute path.

When you launch a program, your program's current working directory is wherever you were when you launched it. Also, you can change the working directory using
shell.setDir("mySubDir")

So, if you have a subdirectory called mySubDir, and in that directory you have a file called a.txt, and if your working directory was in the mySubDir, and you ran the following statements:
> cd mySubDir
mySubDir> lua
lua> shell.resolve("a.txt")

You would get back:
mySubDir/a.txt

Pretty much only useful for either really complicated programs, or programs that are loaded into the programs directory, and thus can be run from any directory (programs like 'edit')
H4X0RZ #3
Posted 10 May 2013 - 04:27 AM
Thank you so much guy!
PixelToast #4
Posted 10 May 2013 - 10:42 AM
unlike fs.combine("",dir) it will also resolve program paths

> shell.resolve("ls")
rom/programs/ls
it ignores the current directory if you put a slash infront of it
it will also resolve backward indexes (../)