X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=filebrowser%2Fdir.c;h=820422ede9423d19fc85471c2d3e0183167fe705;hb=a7db862b2f44d23b358a1319cd8a374cf88c24fd;hp=2ff53070758d86d85acd6663d0efb8c99e56c519;hpb=b4c2ef53cf5a608a9488ed5cf53da908e9553d21;p=xboard.git diff --git a/filebrowser/dir.c b/filebrowser/dir.c index 2ff5307..820422e 100644 --- a/filebrowser/dir.c +++ b/filebrowser/dir.c @@ -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++; }