X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=filebrowser%2Fdir.c;h=820422ede9423d19fc85471c2d3e0183167fe705;hb=a7db862b2f44d23b358a1319cd8a374cf88c24fd;hp=123d329caec9c3dfc28ece08b353ec2f5e651760;hpb=d2f43d6c61f76a5b3999db2f5a0c8b23b2387a42;p=xboard.git diff --git a/filebrowser/dir.c b/filebrowser/dir.c index 123d329..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, @@ -143,8 +144,16 @@ SFgetDir(dir) } result[i].shown = result[i].real; if(SFpathFlag) { // [HGM] only show directories - struct stat statBuf; 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++; }