internal static ZipArchiveFile Read(ZipArchive archive) { Stream stream = archive.fromStream; ByteBuffer byteBuffer = new ByteBuffer(30); int num = byteBuffer.ReadContentsFrom(stream); if (num == 0) { return(null); } uint num1 = byteBuffer.ReadUInt32(); if (num1 != 67324752) { if (num1 != 33639248) { throw new ApplicationException("Bad ZipFile Header"); } return(null); } if (byteBuffer.ReadUInt16() > 256) { throw new ApplicationException("Zip file requires unsupported features"); } byteBuffer.SkipBytes(2); ZipArchiveFile zipArchiveFile = new ZipArchiveFile(archive, null) { compressionMethod = (ZipArchiveFile.CompressionMethod)byteBuffer.ReadUInt16(), lastWriteTime = ZipArchiveFile.DosTimeToDateTime(byteBuffer.ReadUInt32()), crc32 = new uint?(byteBuffer.ReadUInt32()), compressedLength = (void *)(checked ((int)byteBuffer.ReadUInt32())), length = (long)byteBuffer.ReadUInt32() }; int num2 = byteBuffer.ReadUInt16(); byte[] numArray = new byte[num2]; int num3 = stream.Read(numArray, 0, num2); zipArchiveFile.name = Encoding.UTF8.GetString(numArray).Replace('/', Path.DirectorySeparatorChar); archive.entries[zipArchiveFile.name] = zipArchiveFile; if (num != byteBuffer.Length || num3 != num2 || num2 == 0 || zipArchiveFile.LastWriteTime.Ticks == (long)0) { throw new ApplicationException("Bad Zip File Header"); } if (zipArchiveFile.Name.IndexOfAny(ZipArchiveFile.invalidPathChars) >= 0) { throw new ApplicationException("Invalid File Name"); } if (zipArchiveFile.compressionMethod != ZipArchiveFile.CompressionMethod.None && zipArchiveFile.compressionMethod != ZipArchiveFile.CompressionMethod.Deflate) { throw new ApplicationException(string.Concat("Unsupported compression mode ", zipArchiveFile.compressionMethod)); } if (!archive.IsReadOnly || !stream.CanSeek) { zipArchiveFile.compressedData = new byte[zipArchiveFile.compressedLength]; stream.Read(zipArchiveFile.compressedData, 0, zipArchiveFile.compressedLength); } else { zipArchiveFile.positionOfCompressedDataInArchive = archive.fromStream.Position; stream.Seek((long)zipArchiveFile.compressedLength, SeekOrigin.Current); } return(zipArchiveFile); }