 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
victorprosa
Joined: 14 Jan 2009 Posts: 38
|
Posted: Mon Feb 15, 2010 12:38 pm Post subject: sceIoDread strange behavior... |
|
|
Hello everyone, it's me, again...
I've been working with IO functions for a while, but this is the first time i have to use directory listing...
After a lot of effort, I managed to get the function working, but it's returning an strange behavior...
For testing proposes i've just implemented a count function, but it always gave me an strange result:
real number of directories/files + 3
Then, i decided to print the damn results, and the information was a little bit strange:
(NULL)
.
..
(after the above, the listing goes fine)
What may be going on? |
|
| Back to top |
|
 |
NoEffex
Joined: 27 Nov 2008 Posts: 108
|
Posted: Mon Feb 15, 2010 2:11 pm Post subject: Re: sceIoDread strange behavior... |
|
|
| victorprosa wrote: | Hello everyone, it's me, again...
I've been working with IO functions for a while, but this is the first time i have to use directory listing...
After a lot of effort, I managed to get the function working, but it's returning an strange behavior...
For testing proposes i've just implemented a count function, but it always gave me an strange result:
real number of directories/files + 3
Then, i decided to print the damn results, and the information was a little bit strange:
(NULL)
.
..
(after the above, the listing goes fine)
What may be going on? |
NULL is something, not sure.
. is current working directory
.. is top directory (One above) _________________ Programming with:
Geany + Latest PSPSDK from svn |
|
| Back to top |
|
 |
victorprosa
Joined: 14 Jan 2009 Posts: 38
|
Posted: Tue Feb 16, 2010 12:05 am Post subject: Re: sceIoDread strange behavior... |
|
|
| NoEffex wrote: |
NULL is something, not sure.
. is current working directory
.. is top directory (One above) |
Yeah, i know, but the documentation doesn't help in this case:
| Quote: | Returns:
Read status
* 0 - No more directory entries left
* > 0 - More directory entired to go
* < 0 - Error |
It don't tell what does the NULL mean, and why it is giving me the ".", the ".." is understandable, but it shouldn't be there, as soon as the command should be a directory listing, the ".." should be implemented by a further file explorer... |
|
| Back to top |
|
 |
unsigned int
Joined: 13 Aug 2009 Posts: 22
|
Posted: Tue Feb 16, 2010 2:12 am Post subject: |
|
|
The "." and ".." results are normal behaviour (compare readdir()). The NULL result looks strange, might this be an error in your code?
This works for me:
| Code: |
pspDebugScreenInit();
SceUID id = sceIoDopen("ms0:/psp");
SceIoDirent entry;
while (sceIoDread(id, &entry) > 0)
{
pspDebugScreenPrintf("'%s'\n", entry.d_name);
}
sceIoDclose(id);
|
produces
| Code: | '.'
'..'
'COMMON'
'GAME'
'GAME150'
'RSSCH'
'SAVEDATA'
'SYSTEM'
'THEME'
'RADIOPLAYER'
|
|
|
| Back to top |
|
 |
victorprosa
Joined: 14 Jan 2009 Posts: 38
|
Posted: Tue Feb 16, 2010 12:57 pm Post subject: |
|
|
Well, I discovered that for a strange reason, only MP_ROOT, the folder where i was testing this stuff gives the NULL, LOL
Anyway, I use a similar code, but mine has to be FAR way bigger...
I am using VLF, then, the printf trick doesn't work, my code is a giant, with a lot of if(done > 0) {//do it again}
Hate these kind of dificulties of VLF, but it is so beautiful *.*
If you have any idea to shorten the code, it is apreciated, anyway, thanks for your help.... =] |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Fri Feb 19, 2010 12:20 pm Post subject: |
|
|
The root of a FAT filesystem can have an entry for the volume label. Maybe sceIoDread is catching that.
Be careful to zero the SceIoDirent before passing it to sceIoDopen. If you use the newlib wrappers, they take care of this. |
|
| Back to top |
|
 |
|
|
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
|