Application Path

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Application Path

Post by ADePSP »

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...?
Psilocybeing
Posts: 3
Joined: Thu May 04, 2006 7:26 am

Post by Psilocybeing »

char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH);
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

Psilocybeing wrote:char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH);
Thanks
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

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

Thanks
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

Just use the relative path in your function.

Code: Select all

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
TyRaNiD
Posts: 907
Joined: Sun Jan 18, 2004 12:23 am

Post by TyRaNiD »

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.
ADePSP
Posts: 58
Joined: Thu Jul 13, 2006 9:07 pm

Post by ADePSP »

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
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

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
be2003
Posts: 144
Joined: Thu Apr 20, 2006 2:46 pm

Post by be2003 »

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

Code: Select all

char cwd[512];

int cwd_thread(SceSize args, void *argp)
{
getcwd(cwd,256);
return 0;
}
- be2003
blog
Post Reply