FS#8532 - Code works properly on Sim but not on Target

Attached to Project: Rockbox
Opened by Frank Grisafi (JobVanDam) - Wednesday, 30 January 2008, 19:07 GMT
Last edited by Jonathan Gordon (jdgordon) - Thursday, 31 January 2008, 06:57 GMT
Task Type Bugs
Category Simulator
Status Closed
Assigned To No-one
Operating System Gigabeat F/X
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


I have a Gigabeat F40.
I wanted to make a small plugin for myself that traversed directories. To skip the first two files ('.' and '..') I used the following code:

DIR* dir; //holds the current directory
struct dirent *entry; //holds the current file
char dirPath[MAX_PATH]; //holds the path to the current directory

dir = rb->opendir(dirPath);
entry = rb->readdir(dir);
entry = rb->readdir(dir);

In the simulator the code above worked. After the two readdir() statements entry would contain the first file in the directory.
On the actual target entry would still contain '.' .

I apologize if I reported this without following all proper procedures. If you need more information please let me know.
Thank you.
This task depends upon

Closed by  Jonathan Gordon (jdgordon)
Thursday, 31 January 2008, 06:57 GMT
Reason for closing:  Fixed
Additional comments about closing:  problem solved...

for next time.. this isnt the best place for this sort of support... irc or the dev mailing list
Comment by Peter D'Hoye (petur) - Wednesday, 30 January 2008, 21:57 GMT
I think on target the code always uses dircache. For FAT, the . and .. entries must always come first, but I'm not sure what dircache does with it.

This is what I used for the properties plugin:

while(result && (0 != (entry = rb->readdir(dir))))
if (!rb->strcmp((char *)entry->d_name, ".") ||
!rb->strcmp((char *)entry->d_name, ".."))
continue; /* skip these */
/* do whatever you need to here */

Have a look at the properties plugin, it contains all the directory traversal code you need ;)
Comment by Frank Grisafi (JobVanDam) - Thursday, 31 January 2008, 06:15 GMT
I did get my plugin to work it's just I thought this was a bug so I reported, thank you though for your help.

I actually looked to the stats plugin for help and my if statement looks the same as your example except I didn't use the 'not' operator in front of the strcmp calls.

Again thank you for the help.