X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=filebrowser%2Fdir.c;h=40d13fb9c419710f663eaf372b05b8c400898c9d;hb=55517059338842241bcc8d82b1dec21e92b138da;hp=2ff53070758d86d85acd6663d0efb8c99e56c519;hpb=b4c2ef53cf5a608a9488ed5cf53da908e9553d21;p=xboard.git diff --git a/filebrowser/dir.c b/filebrowser/dir.c index 2ff5307..40d13fb 100644 --- a/filebrowser/dir.c +++ b/filebrowser/dir.c @@ -26,14 +26,12 @@ #include #include /* for qsort */ -#include "../config.h" /* to check for dirent.h */ +#include "config.h" /* to check for dirent.h */ #ifdef SEL_FILE_IGNORE_CASE #include #endif /* def SEL_FILE_IGNORE_CASE */ -#include "selfile.h" - #ifdef HAVE_DIRENT_H #include #else @@ -43,6 +41,8 @@ #include +#include "selfile.h" + #ifdef SEL_FILE_IGNORE_CASE int SFcompareEntries(p, q) @@ -128,6 +128,7 @@ SFgetDir(dir) #endif /* ndef S_IFLNK */ while (dp = readdir(dirp)) { + struct stat statBuf; if (i >= alloc) { alloc = 2 * (alloc + 1); result = (SFEntry *) XtRealloc((char *) result, @@ -142,6 +143,18 @@ SFgetDir(dir) maxChars = len; } result[i].shown = result[i].real; + if(SFpathFlag) { // [HGM] only show directories + if (stat(str, &statBuf) || SFstatChar(&statBuf) != '/') continue; + } else if(SFfilterBuffer[0]) { // [HGM] filter on extension + char *p = SFfilterBuffer, match, *q; + match = !(stat(str, &statBuf) || SFstatChar(&statBuf) != '/'); + do { + if(q = strchr(p, ' ')) *q = 0; + if(strstr(str, p)) match++; + if(q) *q = ' '; + } while(q && (p = q+1)); + if(!match) continue; + } i++; }