1 using System.Collections.Generic;
3 using SharpCompress.Common;
4 using SharpCompress.Common.Zip;
5 using SharpCompress.Common.Zip.Headers;
7 namespace SharpCompress.Reader.Zip
9 internal class ZipReader : AbstractReader<ZipEntry, ZipVolume>
11 private readonly StreamingZipHeaderFactory headerFactory;
12 private readonly ZipVolume volume;
14 internal ZipReader(Stream stream, Options options, string password)
15 : base(options, ArchiveType.Zip)
17 volume = new ZipVolume(stream, options);
18 headerFactory = new StreamingZipHeaderFactory(password);
21 public override ZipVolume Volume
23 get { return volume; }
29 /// Opens a ZipReader for Non-seeking usage with a single volume
31 /// <param name="stream"></param>
32 /// <param name="options"></param>
33 /// <param name="password"></param>
34 /// <returns></returns>
35 public static ZipReader Open(Stream stream, string password = null,
36 Options options = Options.KeepStreamsOpen)
38 stream.CheckNotNull("stream");
39 return new ZipReader(stream, options, password);
44 internal override IEnumerable<ZipEntry> GetEntries(Stream stream)
46 foreach (ZipHeader h in headerFactory.ReadStreamHeader(stream))
50 switch (h.ZipHeaderType)
52 case ZipHeaderType.LocalEntry:
54 yield return new ZipEntry(new StreamingZipFilePart(h as LocalEntryHeader,
58 case ZipHeaderType.DirectoryEnd: