Ejemplo n.º 1
0
 public static bool IsZipFile(Stream stream)
 {
     try
     {
         ZipHeader header = ZipHeaderFactory.ReadHeaderNonseekable(stream).FirstOrDefault();
         if (header == null)
         {
             return(false);
         }
         return(Enum.IsDefined(typeof(ZipHeaderType), header.ZipHeaderType));
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
        protected override IEnumerable <ZipArchiveEntry> LoadEntries(IEnumerable <ZipVolume> volumes)
        {
            foreach (ZipHeader h in ZipHeaderFactory.ReadHeaderNonseekable(volumes.Single().Stream))
            {
                if (h != null)
                {
                    switch (h.ZipHeaderType)
                    {
                    case ZipHeaderType.LocalEntry:
                    {
                        yield return(new ZipArchiveEntry(new ZipFilePart(h as LocalEntryHeader)));
                    }
                    break;

                    case ZipHeaderType.DirectoryEnd:
                    {
                        yield break;
                    }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        internal override IEnumerable <ZipEntry> GetEntries(Stream stream, Options options)
        {
            foreach (ZipHeader h in ZipHeaderFactory.ReadHeaderNonseekable(stream))
            {
                if (h != null)
                {
                    switch (h.ZipHeaderType)
                    {
                    case ZipHeaderType.LocalEntry:
                    {
                        yield return(new ZipEntry(new ZipFilePart(h as LocalEntryHeader)));
                    }
                    break;

                    case ZipHeaderType.DirectoryEnd:
                    {
                        yield break;
                    }
                    }
                }
            }
        }