Пример #1
0
        protected override IEnumerable <UPath> EnumeratePathsImpl(UPath path, string searchPattern, SearchOption searchOption, SearchTarget searchTarget)
        {
            var search = SearchPattern.Parse(ref path, ref searchPattern);

            return(zip.Cast <ZipEntry>().Map(x => {
                if (searchTarget == SearchTarget.File && !x.IsFile)
                {
                    return null;
                }
                if (searchTarget == SearchTarget.Directory && !x.IsDirectory)
                {
                    return null;
                }
                UPath child = UPath.DirectorySeparator + x.Name;
                if (!child.FullName.StartsWith(path.FullName))
                {
                    return null;
                }
                if (searchOption == SearchOption.TopDirectoryOnly)
                {
                    child = child.RemovePrefix(path).GetFirstPart();
                }
                if (!search.Match(child))
                {
                    return null;
                }
                return child;
            }).Filter(x => x != null).Distinct());
        }