I'm trying to print out a list of the contents of a directory.
The code compiles correctly but when I execute it on the PSP, it freezes and turns off automatically after a few seconds.
No, you want to zero it before you call sceiodread, not after.
Just use opendir/readdir/closedir in newlib, we've already taken the trouble to work around issues like this.
jimparis wrote:No, you want to zero it before you call sceiodread, not after.
Just use opendir/readdir/closedir in newlib, we've already taken the trouble to work around issues like this.
and it's what happens in this code
at the start folder should be empty (and the first time sceiodread is called it always work even without work arounds)
then it printfs, memset to 0 and then sceiodread is called again so the code is correct :P
The compiler says
"main.c: In function 'main':
main.c:115: warning: implicit declaration of function 'memset'
main.c:115: warning: incompatible implicit declaration of built-in function 'memset'".
...And the code works ! Thanks a lot everybody :D .
Don't you mind if I post my variant?
I was sure that weltall's words "memset the folder struct to zero every time you do the sceiodread. someone should put this in the headers..." was enough, but you need some code, so, there is mine:
IIRC you don't need the memset before every sceIoDread call just before you call it the first time (thats what I saw in samples, and what worked for me).
So it would be a waste of cycles if you do it inside the while loop,
once before the loop is enough.