| View previous topic :: View next topic |
| Author |
Message |
ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Thu Nov 30, 2006 1:56 am Post subject: Application Path |
|
|
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 |
|
 |
Psilocybeing
Joined: 04 May 2006 Posts: 3
|
Posted: Thu Nov 30, 2006 3:41 am Post subject: |
|
|
char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH); |
|
| Back to top |
|
 |
ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Thu Nov 30, 2006 4:44 am Post subject: |
|
|
| Psilocybeing wrote: | char path[MAX_PATH_LENGTH+1];
getcwd(path, MAX_PATH_LENGTH); |
Thanks |
|
| Back to top |
|
 |
ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Thu Nov 30, 2006 4:54 am Post subject: |
|
|
Help, that command only works in User mode... Does anybody know the Kernel mode equivalent...?
Thanks |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
Posted: Thu Nov 30, 2006 8:36 am Post subject: |
|
|
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 |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Fri Dec 01, 2006 1:41 am Post subject: |
|
|
| 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 |
|
 |
ADePSP
Joined: 13 Jul 2006 Posts: 58
|
Posted: Fri Dec 01, 2006 6:28 am Post subject: |
|
|
| 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 |
|
 |
be2003
Joined: 20 Apr 2006 Posts: 144
|
Posted: Sat Dec 02, 2006 2:58 pm Post subject: |
|
|
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 |
|
 |
be2003
Joined: 20 Apr 2006 Posts: 144
|
Posted: Sat Dec 02, 2006 4:13 pm Post subject: |
|
|
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 |
|
 |
|