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 

Application Path

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



Joined: 13 Jul 2006
Posts: 58

PostPosted: Thu Nov 30, 2006 1:56 am    Post subject: Application Path Reply with quote

Is there a way to get the full path of the code that is running...?

I have a prx module and it has a config file which i've hardcoded the location of but i've discovered that sometimes you might need to have the prx in different locations... The ideal solution is to have the prx look for the config file in the same location as itself...

Can anybody help...?
Back to top
View user's profile Send private message
Psilocybeing



Joined: 04 May 2006
Posts: 3

PostPosted: Thu Nov 30, 2006 3:41 am    Post subject: Reply with quote

char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH);
Back to top
View user's profile Send private message
ADePSP



Joined: 13 Jul 2006
Posts: 58

PostPosted: Thu Nov 30, 2006 4:44 am    Post subject: Reply with quote

Psilocybeing wrote:
char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH);


Thanks
Back to top
View user's profile Send private message
ADePSP



Joined: 13 Jul 2006
Posts: 58

PostPosted: Thu Nov 30, 2006 4:54 am    Post subject: Reply with quote

Help, that command only works in User mode... Does anybody know the Kernel mode equivalent...?

Thanks
Back to top
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Thu Nov 30, 2006 8:36 am    Post subject: Reply with quote

Just use the relative path in your function.

Code:
fopen("config.txt", "r");


This method doesn't work for the sceIo* variants, see this thread for further information http://forums.ps2dev.org/viewtopic.php?t=6567
Back to top
View user's profile Send private message
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Fri Dec 01, 2006 1:41 am    Post subject: Reply with quote

There is no general way to get the path of the running module (like say GetModulePath in Windows) because the PSP kernel doesn't store it. Most apps rely on the path to the executable being passed as the first argument to the main function which depending on how your code is being loaded may not be correct.
Back to top
View user's profile Send private message
ADePSP



Joined: 13 Jul 2006
Posts: 58

PostPosted: Fri Dec 01, 2006 6:28 am    Post subject: Reply with quote

TyRaNiD wrote:
There is no general way to get the path of the running module (like say GetModulePath in Windows) because the PSP kernel doesn't store it. Most apps rely on the path to the executable being passed as the first argument to the main function which depending on how your code is being loaded may not be correct.


Thanks, I guess i'll just have to check a selection of locations then...

@Insert_witty_name: I can't do that because it also doesn't work with prx modules unfortunatly...

Thanks for all the help,
ADe
Back to top
View user's profile Send private message
be2003



Joined: 20 Apr 2006
Posts: 144

PostPosted: Sat Dec 02, 2006 2:58 pm    Post subject: Reply with quote

maybe you could load and start a user mode prx from your module that would export a function that returns the cwd... just a though, i think the same idea was used in luaplayer for loading modules
_________________
- be2003
blog
Back to top
View user's profile Send private message
be2003



Joined: 20 Apr 2006
Posts: 144

PostPosted: Sat Dec 02, 2006 4:13 pm    Post subject: Reply with quote

quick thought... make a user mode thread that stores the cwd in a global variable
Code:

char cwd[512];

int cwd_thread(SceSize args, void *argp)
{
getcwd(cwd,256);
return 0;
}

_________________
- be2003
blog
Back to top
View user's profile Send private message
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