Ejemplo n.º 1
0
        public override IEnumerable <Directory> GetAllDirectories(string[] exclusions = null)
        {
            Initialize();

            ZipArchiveEntry[] entries = Archive.Entries.AsParallel()
                                        .Where(e => e.FullName.EndsWith("/"))
                                        .OrderBy(e => e.FullName)                // TODO: Very costly
                                        .ToArray();

            // Wrap all folders and rebuild parents
            List <ZipDirectory> directories = new List <ZipDirectory>(entries.Length);

            foreach (ZipArchiveEntry entry in entries)
            {
                if (exclusions != null && exclusions.Any(e => MatchPattern("/" + entry.FullName, e)))
                {
                    continue;
                }

                ZipDirectory parent = directories.Reverse <ZipDirectory>().FirstOrDefault(d => entry.FullName.StartsWith(d.directory.FullName)); // TODO: Optimize StartsWith call with reverse string match test
                directories.Add(new ZipDirectory(this, parent ?? Root, entry));
            }

            // Return each directory
            yield return(Root);

            foreach (ZipDirectory directory in directories)
            {
                yield return(directory);
            }
        }
Ejemplo n.º 2
0
        public override void DeleteDirectory(Directory directory)
        {
            ZipDirectory zipDirectory = directory as ZipDirectory;

            zipDirectory.directory.Delete();

            storage.Modified = true;
        }
Ejemplo n.º 3
0
        public override void DeleteDirectory(Directory directory)
        {
            if (!directory.Parent.Equals(this))
            {
                throw new ArgumentException("The specified directory could not be found");
            }

            ZipDirectory zipDirectory = directory as ZipDirectory;

            zipDirectory.directory.Delete();

            storage.Modified = true;
        }