ComputerCraft Forums

ComputerCraft => Ask a Pro => Topic started by: at large 0010 on Sep 27, 2020, 11:37 PM

Title: Finding file directory
Post by: at large 0010 on Sep 27, 2020, 11:37 PM
I'm trying to find the directory path of file running but it seems as though I have to already know the path of the file using fs.getDir(). My file is in a directory like "dir/dir/myFile" and I was trying to use "fs.getDir("myFile")", my hopes was that it would return something like "dir/dir/" but alas, it did not work. Any ideas?
Title: Finding file directory
Post by: Lupus590 on Sep 28, 2020, 12:33 AM
This will do what you want.

fs.getDir(shell.getRunningProgram())

fs.getDir needs a file path, shell.getRunningProgram gets the full file path of the file, passing this to getDir gives the result that you want.