예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <summary>
        /// Returns <see cref="Path" /> instances matching the specified pattern.
        /// </summary>
        /// <param name="pattern">The pattern to match.</param>
        /// <param name="predicate">The predicate used to filter directories based on file system information.</param>
        /// <returns>
        ///   <see cref="Path" /> instances matching the specified pattern.
        /// </returns>
        public IEnumerable <Path> Match(string pattern, Func <IDirectory, bool> predicate)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException("pattern");
            }
            if (string.IsNullOrWhiteSpace(pattern))
            {
                return(Enumerable.Empty <Path>());
            }

            // Parse the pattern into an AST.
            var root = _parser.Parse(pattern, _environment.IsUnix());

            // Visit all nodes in the parsed patterns and filter the result.
            return(_visitor.Walk(root, predicate)
                   .Select(x => x.Path)
                   .Distinct(_comparer));
        }
예제 #3
0
        /// <inheritdoc/>
        public IEnumerable <Path> Match(string pattern, GlobberSettings settings)
        {
            if (pattern == null)
            {
                throw new ArgumentNullException(nameof(pattern));
            }

            if (string.IsNullOrWhiteSpace(pattern))
            {
                return(Enumerable.Empty <Path>());
            }

            // Make sure we got some settings.
            settings ??= new GlobberSettings();

            // Parse the pattern into an AST.
            var root = _parser.Parse(pattern, settings.Comparer ?? PathComparer.Default);

            // Visit all nodes in the parsed patterns and filter the result.
            return(_visitor.Walk(root, settings)
                   .Select(x => x.Path)
                   .Distinct(settings.Comparer ?? PathComparer.Default));
        }