將 ScanDir 處理的名稱統一轉成小寫,便利副檔名過濾。
壞處是:對中文路徑名的誤判度再次加大...
void setup (TClass* ref, PFT enter, PFT scan, char* sFilter=0) { char* c; obj = ref; process_enter = enter; process_each_scan = scan; nFilter = 0; if (sFilter) for (char* p=sFilter; *p; ++p) if (*p == '.') { strncpy (filter[nFilter], sFilter, p-sFilter); filter [nFilter][p-sFilter] = '\0'; for (c=filter[nFilter]; *c; ++c) if ('A'<=*c && *c<='Z') *c^=('A'^'a'); nFilter++; sFilter = p+1; } } bool match_filter () //過濾副檔名 { //若副檔名存在 filter int i; //集合中則回傳 true static char fname[128]; char* s = curFile->name; char* p = s + strlen (s) - 1; for (i=0 ;p>s && i<8; ++i, --p) if (*p == '.') {p++; break;} if (i > 0) { //副檔名至少要有一個字元 strcpy (fname, p); for (char* c=fname; *c; ++c) //轉成小寫 if ('A'<=*c && *c<='Z') *c^=('A'^'a'); for (i=0; i<nFilter; ++i) if (strcmp (fname, filter[i]) == 0) return true; } return false; }
沒有留言:
張貼留言