But it looks like fioDread sort files by date, and I wish it could sort files by alphabetical order.
Is there a way to do it?
this is the code I'm using:
Code: Select all
while (fioDread(ret, &record) > ) { ... }
Code: Select all
while (fioDread(ret, &record) > ) { ... }
It's not THAT tough! Here's my sort routine used in Doom on the PSP after I load the entries from the current directory.kouky wrote:Oh my god!
That's gonna be tough job to write bymyself code to sort it by alphabetical order...
Thanks for your quick reply
Code: Select all
// sort them!
for (i=0; i<maxfiles-1; i++)
{
char tempfilename[FILENAME_MAX];
char temppath[FILENAME_MAX];
int tempflags;
if ((!thefiles[i].flags && thefiles[i+1].flags) || // directories first
(thefiles[i].flags && thefiles[i+1].flags && strcasecmp(thefiles[i].filename, thefiles[i+1].filename) > 0) ||
(!thefiles[i].flags && !thefiles[i+1].flags && strcasecmp(thefiles[i].filename, thefiles[i+1].filename) > 0))
{
strcpy(tempfilename, thefiles[i].filename);
strcpy(temppath, thefiles[i].path);
tempflags = thefiles[i].flags;
strcpy(thefiles[i].filename, thefiles[i+1].filename);
strcpy(thefiles[i].path, thefiles[i+1].path);
thefiles[i].flags = thefiles[i+1].flags;
strcpy(thefiles[i+1].filename, tempfilename);
strcpy(thefiles[i+1].path, temppath);
thefiles[i+1].flags = tempflags;
i = -1;
}
}