Index: apps/filetree.c =================================================================== --- apps/filetree.c (revision 31407) +++ apps/filetree.c (working copy) @@ -52,6 +52,7 @@ #include "radio.h" #endif #include "wps.h" +#include "logf.h" static int compare_sort_dir; /* qsort key for sorting directories */ @@ -323,6 +324,14 @@ int ft_load(struct tree_context* c, cons continue; } + /* Hide empty directories */ + /* XXX:Empty directories are displayed until dircache is initialized */ + if ((*c->dirfilter != SHOW_ALL) && + (info.attribute & ATTR_DIREMPTY)) { + logf("filetree: %s", entry->d_name); + continue; + } + dptr->attr = info.attribute; /* check for known file types */ Index: firmware/include/dir.h =================================================================== --- firmware/include/dir.h (revision 31407) +++ firmware/include/dir.h (working copy) @@ -50,6 +50,8 @@ #define ATTR_VOLUME 0x40 /* this is a volume, not a real directory */ #define ATTR_LINK 0x80 +#define ATTR_DIREMPTY 0x100 + #ifdef HAVE_DIRCACHE # include "dircache.h" # define DIR DIR_CACHED Index: firmware/common/dircache.c =================================================================== --- firmware/common/dircache.c (revision 31407) +++ firmware/common/dircache.c (working copy) @@ -312,6 +312,7 @@ static int sab_process_dir(unsigned long /* first pass : read dir */ struct dircache_entry *first_ce = ce; + int fc = 0; /* file counter */ /* read through directory */ while((rc = fat_getnext(sab.dir, sab.direntry)) >= 0 && sab.direntry->name[0]) @@ -371,9 +372,22 @@ static int sab_process_dir(unsigned long if(ce->d_name != NULL && ce->down != NULL && strcmp(ce->d_name, ".") && strcmp(ce->d_name, "..")) rc = sab_process_dir(ce->startcluster, ce->down); + + if (ce->info.attribute & ATTR_DIRECTORY) { + if (strcmp(ce->d_name, ".") && strcmp(ce->d_name, "..") && + !(ce->info.attribute & ATTR_DIREMPTY)) + fc++; + } else + fc++; ce = ce->next; } + + if (first_ce->up && !fc) + { + logf("empty: %s", first_ce->up->d_name); + first_ce->up->info.attribute |= ATTR_DIREMPTY; + } return rc; } @@ -424,6 +438,7 @@ static int sab_process_dir(struct dircac return -1; } + int fc = 0; /* file counter */ while((entry = readdir_uncached(dir))) { if(!strcmp(".", entry->d_name) || @@ -460,6 +475,10 @@ static int sab_process_dir(struct dircac closedir_uncached(dir); return rc; } + if (!(ce->info.attribute & ATTR_DIREMPTY)) + fc++; + } else { + fc++; } ce = dircache_gen_next(ce); @@ -475,6 +494,11 @@ static int sab_process_dir(struct dircac yield(); } } + + if (first_ce->up && !fc) { + logf("empty: %s", first_ce->up->d_name); + first_ce->up->info.attribute |= ATTR_DIREMPTY; + } /* add "." and ".." */ ce->d_name = dot;