Mercurial > foo_out_sdl
comparison foosdk/sdk/pfc/wildcard.cpp @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #include "pfc-lite.h" | |
| 2 #include "wildcard.h" | |
| 3 #include "string_base.h" | |
| 4 | |
| 5 static bool test_recur(const char * fn,const char * rm,bool b_sep) | |
| 6 { | |
| 7 for(;;) | |
| 8 { | |
| 9 if ((b_sep && *rm==';') || *rm==0) return *fn==0; | |
| 10 else if (*rm=='*') | |
| 11 { | |
| 12 rm++; | |
| 13 do | |
| 14 { | |
| 15 if (test_recur(fn,rm,b_sep)) return true; | |
| 16 } while(pfc::utf8_advance(fn)); | |
| 17 return false; | |
| 18 } | |
| 19 else if (*fn==0) return false; | |
| 20 else if (*rm!='?' && pfc::charLower(pfc::utf8_get_char(fn))!=pfc::charLower(pfc::utf8_get_char(rm))) return false; | |
| 21 | |
| 22 fn = pfc::utf8_char_next(fn); rm = pfc::utf8_char_next(rm); | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 bool wildcard_helper::test_path(const char * path,const char * pattern,bool b_sep) {return test(path + pfc::scan_filename(path),pattern,b_sep);} | |
| 27 | |
| 28 bool wildcard_helper::test(const char * fn,const char * pattern,bool b_sep) | |
| 29 { | |
| 30 if (!b_sep) return test_recur(fn,pattern,false); | |
| 31 const char * rm=pattern; | |
| 32 while(*rm) | |
| 33 { | |
| 34 if (test_recur(fn,rm,true)) return true; | |
| 35 while(*rm && *rm!=';') rm++; | |
| 36 if (*rm==';') | |
| 37 { | |
| 38 while(*rm==';') rm++; | |
| 39 while(*rm==' ') rm++; | |
| 40 } | |
| 41 }; | |
| 42 | |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 bool wildcard_helper::has_wildcards(const char * str) {return strchr(str,'*') || strchr(str,'?');} | |
| 47 | |
| 48 const char * wildcard_helper::get_wildcard_list() {return "*?";} | |
| 49 | |
| 50 bool wildcard_helper::is_wildcard(char c) { | |
| 51 return c == '*' || c == '?'; | |
| 52 } |
