sceIoDread strange behavior...

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
victorprosa
Posts: 37
Joined: Wed Jan 14, 2009 5:53 am

sceIoDread strange behavior...

Post by victorprosa »

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?
NoEffex
Posts: 106
Joined: Thu Nov 27, 2008 6:48 am

Re: sceIoDread strange behavior...

Post by NoEffex »

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
victorprosa
Posts: 37
Joined: Wed Jan 14, 2009 5:53 am

Re: sceIoDread strange behavior...

Post by victorprosa »

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:
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...
unsigned int
Posts: 18
Joined: Thu Aug 13, 2009 11:42 pm

Post by unsigned int »

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: Select all

  pspDebugScreenInit&#40;&#41;;

  SceUID id = sceIoDopen&#40;"ms0&#58;/psp"&#41;;
  SceIoDirent entry;
  while &#40;sceIoDread&#40;id, &entry&#41; > 0&#41;
  &#123;
    pspDebugScreenPrintf&#40;"'%s'\n", entry.d_name&#41;;
  &#125;
  sceIoDclose&#40;id&#41;;
produces

Code: Select all

'.'
'..'
'COMMON'
'GAME'
'GAME150'
'RSSCH'
'SAVEDATA'
'SYSTEM'
'THEME'
'RADIOPLAYER'
victorprosa
Posts: 37
Joined: Wed Jan 14, 2009 5:53 am

Post by victorprosa »

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.... =]
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

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.
Post Reply