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 

sceIoDread strange behavior...

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



Joined: 14 Jan 2009
Posts: 38

PostPosted: Mon Feb 15, 2010 12:38 pm    Post subject: sceIoDread strange behavior... Reply with quote

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



Joined: 27 Nov 2008
Posts: 108

PostPosted: Mon Feb 15, 2010 2:11 pm    Post subject: Re: sceIoDread strange behavior... Reply with quote

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



Joined: 14 Jan 2009
Posts: 38

PostPosted: Tue Feb 16, 2010 12:05 am    Post subject: Re: sceIoDread strange behavior... Reply with quote

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
View user's profile Send private message Send e-mail
unsigned int



Joined: 13 Aug 2009
Posts: 22

PostPosted: Tue Feb 16, 2010 2:12 am    Post subject: Reply with quote

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



Joined: 14 Jan 2009
Posts: 38

PostPosted: Tue Feb 16, 2010 12:57 pm    Post subject: Reply with quote

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



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Fri Feb 19, 2010 12:20 pm    Post subject: Reply with quote

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