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 

Writing files and reading directories

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



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Oct 25, 2008 4:43 am    Post subject: Writing files and reading directories Reply with quote

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



Joined: 05 Jul 2008
Posts: 229

PostPosted: Sat Oct 25, 2008 5:05 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Oct 25, 2008 5:22 am    Post subject: Reply with quote

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



Joined: 05 Oct 2008
Posts: 40

PostPosted: Sat Oct 25, 2008 8:03 am    Post subject: Reply with quote

Check your return codes to see what one is failing.
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Oct 25, 2008 5:54 pm    Post subject: Reply with quote

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



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Sat Oct 25, 2008 7:14 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Oct 25, 2008 9:52 pm    Post subject: Reply with quote

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



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Oct 25, 2008 10:22 pm    Post subject: Reply with quote

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



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sat Oct 25, 2008 10:28 pm    Post subject: Reply with quote

Nope neither 1.50 kernel addon
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Sat Oct 25, 2008 11:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail MSN Messenger
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Sun Oct 26, 2008 12:12 am    Post subject: Reply with quote

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
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