/// <summary> /// Returns <see cref="Path" /> instances matching the specified pattern. /// </summary> /// <param name="globber">The globber.</param> /// <param name="pattern">The pattern to match.</param> /// <returns> /// <see cref="Path" /> instances matching the specified pattern. /// </returns> public static IEnumerable <Path> Match(this IGlobber globber, GlobPattern pattern) { if (globber == null) { throw new ArgumentNullException(nameof(globber)); } return(globber.Match(pattern, new GlobberSettings())); }
/// <summary> /// Gets all files matching the specified pattern. /// </summary> /// <param name="globber">The globber.</param> /// <param name="pattern">The pattern.</param> /// <returns>The files matching the specified pattern.</returns> public static IEnumerable <FilePath> GetFiles(this IGlobber globber, GlobPattern pattern) { if (globber == null) { throw new ArgumentNullException(nameof(globber)); } return(globber.Match(pattern).OfType <FilePath>()); }
/// <inheritdoc/> public IEnumerable <Path> Match(GlobPattern pattern, GlobberSettings settings) { if (pattern == null) { throw new ArgumentNullException(nameof(pattern)); } if (string.IsNullOrWhiteSpace(pattern?.Pattern)) { return(Enumerable.Empty <Path>()); } // Parse the pattern into an AST. var root = _parser.Parse(pattern, settings); // Visit all nodes in the parsed patterns and filter the result. return(_visitor.Walk(root, settings) .Select(x => x.Path) .Distinct(_comparer)); }