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); }
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; }
internal PathFilter Build() { return(PathFilter.Create(_BasePath, _Expressions.ToArray(), _MatchResult)); }
private bool ShouldInclude(string file, PathFilter filter) { return((filter == null || filter.Match(file)) && (_GlobalFilter == null || _GlobalFilter.Match(file))); }
/// <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)); }