Changeset 5307 for trunk/MagicSoft/Mars/mbase/MDirIter.cc
- Timestamp:
- 10/22/04 15:59:02 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/MDirIter.cc
r5299 r5307 202 202 // -------------------------------------------------------------------------- 203 203 // 204 // As the filter string may contain a + character, we have to replace 205 // this filter by a new filter contaning a \+ at all locations where a + 206 // was in the original filter. 207 // 208 // We replace: 209 // . by \\. 210 // + by \\+ 211 // * by [^\\/:]* 212 // ? by . 213 // 214 // And surround the filter by ^ and $. 215 // 216 // For more details you can have a look at the template: 217 // TRegexp::MakeWildcard 218 // 219 const TRegexp MDirIter::MakeRegexp(TString n) const 220 { 221 n.Prepend("^"); 222 n.ReplaceAll(".", "\\."); 223 n.ReplaceAll("+", "\\+"); 224 n.ReplaceAll("*", "[^\\/:]*"); 225 n.ReplaceAll("?", "."); 226 n.Append("$"); 227 228 return TRegexp(n, kFALSE); 229 } 230 231 // -------------------------------------------------------------------------- 232 // 204 233 // Check whether the given name n matches the filter f. 205 234 // Filters are of the form TRegexp(f, kTRUE) … … 207 236 Bool_t MDirIter::MatchFilter(const TString &n, const TString &f) const 208 237 { 209 // As the filter string may contain a + character, we have to replace 210 // this filter by a new filter contaning a \+ at all locations where a + 211 // was in the original filter. 212 TString nf(f); 213 nf.ReplaceAll("+","\\+"); 214 215 return f.IsNull() || !n(TRegexp(nf, kTRUE)).IsNull(); 238 239 return f.IsNull() || !n(MakeRegexp(f)).IsNull(); 216 240 } 217 241
Note:
See TracChangeset
for help on using the changeset viewer.