#165273 - DiscoStew - Mon Dec 15, 2008 10:31 pm
I just got finished with using Maxmod to stream WAV files (PCM specific) from a specific location using libfat, but now I want to be able to allow the user to go through directories to search for compatible WAV files to play.
I started with the libfat example that scans the root directory for folders and files and displays them as such, but I'm having a bit of trouble when opendir doesn't use the root directory. Everything read with a different directory is showing up as folders, both folders and files.
This is the simple change I made...
Am I doing something wrong? Also, if I am to switch to a new directory, would I need to close the current one, and then reopen the new one with opendir?
_________________
DS - It's all about DiscoStew
I started with the libfat example that scans the root directory for folders and files and displays them as such, but I'm having a bit of trouble when opendir doesn't use the root directory. Everything read with a different directory is showing up as folders, both folders and files.
This is the simple change I made...
Code: |
DIR *pdir;
struct dirent *pent; struct stat statbuf; //pdir=opendir("/"); pdir=opendir("/data/"); <----------------------- if (pdir) { while ((pent=readdir(pdir))!=NULL) { stat(pent->d_name,&statbuf); if(strcmp(".", pent->d_name) == 0 || strcmp("..", pent->d_name) == 0) continue; if(S_ISDIR(statbuf.st_mode)) iprintf("%s <dir>\n", pent->d_name); if(!(S_ISDIR(statbuf.st_mode))) iprintf("%s %ld\n", pent->d_name, statbuf.st_size); } closedir(pdir); } else { iprintf ("opendir() failure; terminating\n"); } while(1) swiWaitForVBlank(); |
Am I doing something wrong? Also, if I am to switch to a new directory, would I need to close the current one, and then reopen the new one with opendir?
_________________
DS - It's all about DiscoStew