gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > help with FAT lib

#83246 - D-loader - Sun May 14, 2006 2:00 pm

Hi

I hope somebody in here, can help me with a lil problem I have:

Code:

int filenum = 1;

void list() {
   char fname[128];
   
   char type[128];
   enum { NO_MORE = 0, FILE = 1, DIR = 2 };   
   int entryType = FAT_FindFirstFile(fname);

   switch(entryType){
   case 0: {} break;
   case 1: { sprintf(type,"File");} break;
   case 2: { sprintf(type,"Folder");} break;
   }
   
   

   while (entryType != NO_MORE) {
      iprintf("%d.%s = %s\n",filenum,fname,type);
      entryType = FAT_FindNextFile(fname);
     filenum++;
   }

   iprintf("....");
}


the problem is.. no matter what I do, it always shows up as files only, or folders only.. have I placed my breaks wrong?[/code]

#83247 - zzo38computer - Sun May 14, 2006 2:03 pm

Maybe this will fix it
Code:

int filenum = 1;

void list() {
   char fname[128];
   
   char type[128];
   enum { NO_MORE = 0, FILE = 1, DIR = 2 };   
   int entryType = FAT_FindFirstFile(fname);

   
   

   while (entryType != NO_MORE) {
     switch(entryType){
       case 0: {} break;
       case 1: { sprintf(type,"File");} break;
       case 2: { sprintf(type,"Folder");} break;
     }
     iprintf("%d.%s = %s\n",filenum,fname,type);
     entryType = FAT_FindNextFile(fname);
     filenum++;
   }

   iprintf("....");
}

_________________
Important: Please send messages about FWNITRO to the public forum, not privately to me.

#83248 - D-loader - Sun May 14, 2006 2:07 pm

it did, thanks =)

#83275 - HyperHacker - Sun May 14, 2006 11:26 pm

Just FYI:
case 0: break;
is acceptable in all compilers I know of. Looks better too.

#83307 - chishm - Mon May 15, 2006 6:43 am

HyperHacker wrote:
Just FYI:
case 0: break;
is acceptable in all compilers I know of. Looks better too.

Even more (or less) confusing: you can remove the {} from within individual cases, so it would be like:
Code:
     switch(entryType){
       case 0:  break;
       case 1: sprintf(type,"File"); break;
       case 2: sprintf(type,"Folder"); break;
     }

_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com