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

[ Help ] Access Denied

Started by AnthonyD98™, 07 February 2013 - 07:14 PM
AnthonyD98™ #1
Posted 07 February 2013 - 08:14 PM
file = shell.path()
fs.makeDir(file.."/sel")
-- toast:2: Access Denied

I'm in the root directory, how do I fix this?

Thanks, AnthonyD98

( If your wondering why my program is called toast and is so short is because its for testing code for a much bigger program )
tesla1889 #2
Posted 07 February 2013 - 08:24 PM
shell.path is still set to somewhere in /rom

shell.setPath to change it

btw, no questions asked on program names. there are some weird names out there in the real world too
theoriginalbit #3
Posted 07 February 2013 - 08:29 PM
do a print on shell.path() its like 3 crazy paths in /rom

you clearly didn't read my edit properly in the OTHER thread.
AnthonyD98™ #4
Posted 07 February 2013 - 08:32 PM
do a print on shell.path() its like 3 crazy paths in /rom

you clearly didn't read my edit properly in the OTHER thread.

Sorry, I didn't really undertstand your edit.
theoriginalbit #5
Posted 07 February 2013 - 08:35 PM
Sorry, I didn't really undertstand your edit.
Then you should have asked me there instead of posting a new topic…

Lets try this again:
There is no way to get the currently running programs file path. We have to write it ourself. Like this

function getPath()
  local runningProgram = shell.getRunningProgram()
  local programName = fs.getName( runningProgram )
  return runningProgram:sub( 1, #runningProgram - #programName )
end

fs.makeDir( getPath().."/sel" )
shell.getRunningProgram returns the absolute path of the running program, including the programs name
fs.getName gets that name
then we use string.sub to get the path from the absolute. to do this we tell it to go from the start of the absolute to the end of the absolute minus the name

does this explanation make more sense?
AnthonyD98™ #6
Posted 07 February 2013 - 08:37 PM
Sorry, I didn't really undertstand your edit.
Then you should have asked me there instead of posting a new topic…

Lets try this again:
There is no way to get the currently running programs file path. We have to write it ourself. Like this

function getPath()
  local runningProgram = shell.getRunningProgram()
  local programName = fs.getName( runningProgram )
  return runningProgram:sub( 1, #runningProgram - #programName )
end

fs.makeDir( getPath().."/sel" )

Now I get it after re-reading your orginal post, and reading this.

Thanks ( Sorry for being . . . . an idoit )
AnthonyD98™ #7
Posted 07 February 2013 - 08:39 PM
Your explanation does make sense now.
theoriginalbit #8
Posted 07 February 2013 - 08:42 PM
Your explanation does make sense now.
Cool.
AnthonyD98™ #9
Posted 07 February 2013 - 08:43 PM
I really do appreciate your help - Even linking me with tutorial pages.