| View previous topic :: View next topic |
| Author |
Message |
turkeyman

Joined: 20 Oct 2004 Posts: 75 Location: Brisbane, Australia
|
Posted: Tue Apr 18, 2006 11:29 am Post subject: Current working dir? |
|
|
| Can anyone tell me how to get the current working directory? or rather, since there doesnt seem to be one (all paths seem to be absolute), the directory the elf lives in? |
|
| Back to top |
|
 |
weltall
Joined: 20 Feb 2004 Posts: 310
|
Posted: Tue Apr 18, 2006 4:15 pm Post subject: |
|
|
| you can find it inside argv[0] |
|
| Back to top |
|
 |
turkeyman

Joined: 20 Oct 2004 Posts: 75 Location: Brisbane, Australia
|
Posted: Tue Apr 18, 2006 8:21 pm Post subject: |
|
|
sure?
that was the first thing i tried, but it didnt work..
does that rely on the launcher? or the homebrew libs? |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Tue Apr 18, 2006 8:32 pm Post subject: |
|
|
Depends, argv[0] is setup by the program which loaded the module, if the launcher doesn't do it correct it will not work. The Sony shell does it, psplink does it, not idea about any other launcher.
The libc which comes with the toolchain _should_ extract the current directory information for you and allow you to call open/opendir etc. with relative paths, but best print out argv[0] to see if you have actually got the path to the executable in there. |
|
| Back to top |
|
 |
PeterM
Joined: 31 Dec 2005 Posts: 125 Location: Edinburgh, UK
|
Posted: Tue Apr 18, 2006 11:35 pm Post subject: |
|
|
| You can get the current dir using the getcwd function. I think it lives in unistd.h, but I'm not sure. |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Wed Apr 19, 2006 3:47 am Post subject: |
|
|
eLoader also passes the correct argv[0] by default. You can turn that behaviour off so that it passes NULL, but it's unlikely you've done that.
Note that the stdlib functions all rely on the module being passed the correct argv[] in the first place, if that didn't happen then all standard functions (such as cwd()) will have problems. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
turkeyman

Joined: 20 Oct 2004 Posts: 75 Location: Brisbane, Australia
|
Posted: Wed Apr 19, 2006 9:27 am Post subject: |
|
|
fair call, if you say the sony shell does set it up, then i must have just screwed something up myself..
thanks guys! :P |
|
| Back to top |
|
 |
|