Ejemplo n.º 1
0
        private bool TryFilter(string path, out string searchPattern, out PathFilter filter)
        {
            searchPattern = null;
            filter        = null;
            if (UseSimpleSearch(path))
            {
                return(false);
            }

            filter = PathFilter.Create(_BasePath, path);
            var patternSeparator = path.LastIndexOfAny(PathSeparatorCharacters) + 1;

            searchPattern = path.Substring(patternSeparator, path.Length - patternSeparator);
            return(true);
        }
Ejemplo n.º 2
0
 protected PathBuilder(IPipelineWriter logger, string basePath, string searchPattern, PathFilter filter)
 {
     _Logger               = logger;
     _Files                = new List <InputFileInfo>();
     _Paths                = new HashSet <string>();
     _BasePath             = NormalizePath(PSDocumentOption.GetRootedBasePath(basePath));
     _DefaultSearchPattern = searchPattern;
     _GlobalFilter         = filter;
 }
Ejemplo n.º 3
0
 internal PathFilter Build()
 {
     return(PathFilter.Create(_BasePath, _Expressions.ToArray(), _MatchResult));
 }
Ejemplo n.º 4
0
 private bool ShouldInclude(string file, PathFilter filter)
 {
     return((filter == null || filter.Match(file)) &&
            (_GlobalFilter == null || _GlobalFilter.Match(file)));
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Split a search path into components based on wildcards.
        /// </summary>
        private string GetSearchParameters(string path, out string searchPattern, out SearchOption searchOption, out PathFilter filter)
        {
            searchOption = SearchOption.AllDirectories;
            var pathLiteral = TrimPath(path, out bool relativeAnchor);

            if (TryFilter(pathLiteral, out searchPattern, out filter))
            {
                return(_BasePath);
            }

            pathLiteral = SplitSearchPath(pathLiteral, out searchPattern);
            if ((relativeAnchor || !string.IsNullOrEmpty(pathLiteral)) && !string.IsNullOrEmpty(searchPattern))
            {
                searchOption = SearchOption.TopDirectoryOnly;
            }

            if (string.IsNullOrEmpty(searchPattern))
            {
                searchPattern = _DefaultSearchPattern;
            }

            return(GetRootedPath(pathLiteral));
        }