This class can be used to match filenames against fnmatch like patterns. It is not thread save. Supported are the wildcard characters * and ? and groups with:
  • characters e.g. [abc]
  • ranges e.g. [a-z]
  • the following character classes
    • [:alnum:]
    • [:alpha:]
    • [:blank:]
    • [:cntrl:]
    • [:digit:]
    • [:graph:]
    • [:lower:]
    • [:print:]
    • [:punct:]
    • [:space:]
    • [:upper:]
    • [:word:]
    • [:xdigit:]
    e. g. [[:xdigit:]]
Esempio n. 1
0
        public PathMatcher(string pattern)
        {
            if (string.IsNullOrWhiteSpace(pattern)) throw new ArgumentNullException("pattern");
            if (pattern.StartsWith("!")) throw new ArgumentException("Negated patterns should not be used", "pattern");

            // Strip leading forward slash from pattern as matched paths don't start with the path separator character
            if (pattern.StartsWith(GitIgnorePathSeparator + string.Empty))
                pattern = pattern.Substring(1);

            _matcher = new FileNameMatcher(pattern, GitIgnorePathSeparator);
        }
Esempio n. 2
0
        public DirectoryMatcher(string pattern)
        {
            if (string.IsNullOrWhiteSpace(pattern))
                throw new ArgumentNullException("pattern");

            if (pattern.StartsWith("!"))
                throw new ArgumentException("Negated patterns should not be used", "pattern");

            if (pattern[pattern.Length - 1] != Path.DirectorySeparatorChar)
                throw new ArgumentException("Matches directories only, not files", "pattern");

            _matcher = new FileNameMatcher(pattern.Substring(0, pattern.Length - 1), null);
        }
Esempio n. 3
0
        public FileMatcher(string pattern)
        {
            if (string.IsNullOrWhiteSpace(pattern))
                throw new ArgumentNullException("pattern");

            if (pattern.StartsWith("!"))
                throw new ArgumentException("Negated patterns should not be used", "pattern");

            if (pattern.Contains(Path.DirectorySeparatorChar))
                throw new ArgumentException("Matches files only, not directories", "pattern");

            _matcher = new FileNameMatcher(pattern, null);
        }
Esempio n. 4
0
 ///	<summary>
 /// A copy constructor which creates a new <seealso cref="FileNameMatcher"/> with the
 /// same state and Reset point like <code>other</code>.
 /// </summary>
 /// <param name="other">
 /// another <seealso cref="FileNameMatcher"/> instance.
 /// </param>
 public FileNameMatcher(FileNameMatcher other)
     : this(other._headsStartValue, other._heads)
 {
     if (other == null)
         throw new System.ArgumentNullException("other");
 }