| View previous topic :: View next topic |
| Author |
Message |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sat Oct 25, 2008 4:43 am Post subject: Writing files and reading directories |
|
|
I made a prx which runs in game (not from game.txt) and I made a function to read a directory. The MS light blinks for a long period of time but does not read anything.
This does not create any file:
| Code: | FILE* outFile = fopen("ms0:/test2.jpg", "wb");
fclose(outFile); |
I made a different prx which runs in game (from game.txt) and the only thing it does is create a file and it works perfectly.
Both files run in kernel mode
Are there any restrictions for PRX files when running in game but not as seplugins from game.txt ? _________________
Upgrade your PSP |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Sat Oct 25, 2008 5:05 am Post subject: |
|
|
have you test the natif API like fd = sceIoOpen("device:/path/to/file", O_WRONLY|O_CREAT, 0777) instead of the one got from the glibc
Meaby some stuf on the runtime got into trouble when running in game
context |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sat Oct 25, 2008 5:22 am Post subject: |
|
|
Yeah I've just tested this:
| Code: | int fd = sceIoOpen("ms0:/test.txt", PSP_O_CREAT | PSP_O_WRONLY, 0777);
char data[100];
sprintf(data, "sakdfsngfdg");
sceIoWrite(fd, data, strlen(data));
sceIoClose(fd); |
and as it happened with the read directory function the ms led blinks for a long period of time but this time it created the file but did not write anything. _________________
Upgrade your PSP |
|
| Back to top |
|
 |
Onii
Joined: 05 Oct 2008 Posts: 40
|
Posted: Sat Oct 25, 2008 8:03 am Post subject: |
|
|
| Check your return codes to see what one is failing. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sat Oct 25, 2008 5:54 pm Post subject: |
|
|
Ok so here are the returned values.
| Code: | | int fd = sceIoOpen("ms0:/test.txt", PSP_O_CREAT | PSP_O_WRONLY, 0777); |
Returns a positive number. (so this one is working) Takes at least 10 seconds to create the file.
| Code: | | int bw = sceIoWrite(fd, data, sizeof(data)); |
Returns 80220087 / -214525589 - Error
| Code: | | int close = sceIoClose(fd); |
Returns 0 so it closed the file successfully but just like with sceIoOpen, it blinks for at least 10 seconds.
I think this is due to the fact that I am "pausing" the game
Edit:
Just tested before starting the main thread in my prx and it wrote the file with success. So I guess the problem is I am pausing the game. I need to write the file after resuming the game to confirm this
Edit 2: confirmed _________________
Upgrade your PSP |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Oct 25, 2008 7:14 pm Post subject: |
|
|
| If you're using threads, I think you forgot that the PSP uses COOPERATIVE multitasking. Threads don't run unless you call system routines that switch threads. The most common way to allow other threads to run is to call sceKernelDelayThread(). Calling blocking functions will also allow other threads to run. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sat Oct 25, 2008 9:52 pm Post subject: |
|
|
I do have sceKernelDelayThread in the while loop.
I tried writing the file from the main thread and did not work. The same happened when writing a file from another thread _________________
Upgrade your PSP |
|
| Back to top |
|
 |
Torch

Joined: 28 May 2008 Posts: 842
|
Posted: Sat Oct 25, 2008 10:22 pm Post subject: |
|
|
Do you have the 3.71 fatmsmod.prx for 5.00 patch installed by any chance?
I did some tests and I'm having problems with some IO functions with it installed. |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sat Oct 25, 2008 10:28 pm Post subject: |
|
|
Nope neither 1.50 kernel addon _________________
Upgrade your PSP |
|
| Back to top |
|
 |
sauron_le_noir
Joined: 05 Jul 2008 Posts: 229
|
Posted: Sat Oct 25, 2008 11:54 pm Post subject: |
|
|
Can you post somewhere a EBOOT so we can test your code against
different psp and different kind of memory stick.
Do you have perform some test regression like testing your code on 3.52M33,3.90M33, etc ...... |
|
| Back to top |
|
 |
Pirata Nervo
Joined: 09 Oct 2007 Posts: 409
|
Posted: Sun Oct 26, 2008 12:12 am Post subject: |
|
|
It's not an eboot, it's a prx and I already said the problem was I was "pausing" the game thread. Now that I am not pausing anymore it works perfectly _________________
Upgrade your PSP |
|
| Back to top |
|
 |
|