forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Current working dir?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
turkeyman



Joined: 20 Oct 2004
Posts: 75
Location: Brisbane, Australia

PostPosted: Tue Apr 18, 2006 11:29 am    Post subject: Current working dir? Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Tue Apr 18, 2006 4:15 pm    Post subject: Reply with quote

you can find it inside argv[0]
Back to top
View user's profile Send private message Visit poster's website
turkeyman



Joined: 20 Oct 2004
Posts: 75
Location: Brisbane, Australia

PostPosted: Tue Apr 18, 2006 8:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Tue Apr 18, 2006 8:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
PeterM



Joined: 31 Dec 2005
Posts: 125
Location: Edinburgh, UK

PostPosted: Tue Apr 18, 2006 11:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Fanjita



Joined: 28 Sep 2005
Posts: 217

PostPosted: Wed Apr 19, 2006 3:47 am    Post subject: Reply with quote

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
View user's profile Send private message
turkeyman



Joined: 20 Oct 2004
Posts: 75
Location: Brisbane, Australia

PostPosted: Wed Apr 19, 2006 9:27 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group