public IEnumerable <UPath> EnumeratePaths(UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget) { var search = SearchPattern.Parse(ref path, ref searchPattern); var hashset = new HashSet <UPath>(); // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var entry in this.archive.Entries) { var p = new UPath('/' + entry.FullName); if (searchTarget == SearchTarget.Both || searchTarget == SearchTarget.File) { if (p.IsInDirectory(path, searchOption == SearchOption.AllDirectories) && search.Match(p)) { hashset.Add(p); } } if (searchTarget != SearchTarget.Both && searchTarget != SearchTarget.Directory) { continue; } p = p.GetDirectory(); if (p.IsInDirectory(path, searchOption == SearchOption.AllDirectories) && search.Match(p)) { hashset.Add(p); } } return(hashset); }
protected override UPath?TryConvertPath(UPath pathFromEvent) { if (!pathFromEvent.IsInDirectory(_fileSystem.SubPath, true)) { return(null); } return(_fileSystem.ConvertPathFromDelegate(pathFromEvent)); }
/// <summary> /// Gets the remaining path after the <see cref="prefix"/>. /// </summary> /// <param name="prefix">The prefix of the path.</param> /// <param name="path">The path to search.</param> /// <returns>The path after the prefix, or a <c>null</c> path if <see cref="path"/> does not have the correct prefix.</returns> private static UPath GetRemaining(UPath prefix, UPath path) { if (!path.IsInDirectory(prefix, true)) { return(null); } var remaining = path.FullName.Substring(prefix.FullName.Length); var remainingPath = new UPath(remaining).ToAbsolute(); return(remainingPath); }
/// <summary> /// Gets the remaining path after the <see cref="prefix"/>. /// </summary> /// <param name="self">The path to search.</param> /// <param name="prefix">The prefix of the path.</param> /// <returns>The path after the prefix, or a <c>null</c> path if <see cref="path"/> does not have the correct prefix.</returns> public static UPath RemovePrefix(this UPath self, UPath prefix) { if (prefix.IsEmpty) { throw new InvalidDataException("The passed prefix cant be emtpy, must minimum be the UPath.root"); } if (!self.IsInDirectory(prefix, true)) { throw new InvalidDataException($"Path '{self}' is not in '{prefix}'"); } var remaining = self.FullName.Substring(prefix.FullName.Length); return(new UPath(remaining).ToAbsolute()); }
private bool IsOutputDirectory(UPath path) { return(path.IsInDirectory(SiteObject.BuildFolder, true)); }