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); } }
public override void DeleteDirectory(Directory directory) { ZipDirectory zipDirectory = directory as ZipDirectory; zipDirectory.directory.Delete(); storage.Modified = true; }
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; }