internal static ZipIOLocalFileHeader ParseRecord(BinaryReader reader, Encoding encoding) { ZipIOLocalFileHeader header = new ZipIOLocalFileHeader(); header._signature = reader.ReadUInt32(); header._versionNeededToExtract = reader.ReadUInt16(); header._generalPurposeBitFlag = reader.ReadUInt16(); header._compressionMethod = reader.ReadUInt16(); header._lastModFileDateTime = reader.ReadUInt32(); header._crc32 = reader.ReadUInt32(); header._compressedSize = reader.ReadUInt32(); header._uncompressedSize = reader.ReadUInt32(); header._fileNameLength = reader.ReadUInt16(); header._extraFieldLength = reader.ReadUInt16(); header._fileName = reader.ReadBytes(header._fileNameLength); ZipIOZip64ExtraFieldUsage none = ZipIOZip64ExtraFieldUsage.None; if (header._versionNeededToExtract >= 0x2d) { if (header._compressedSize == uint.MaxValue) { none |= ZipIOZip64ExtraFieldUsage.CompressedSize; } if (header._uncompressedSize == uint.MaxValue) { none |= ZipIOZip64ExtraFieldUsage.UncompressedSize; } } header._extraField = ZipIOExtraField.ParseRecord(reader, none, header._extraFieldLength); header._stringFileName = ZipIOBlockManager.ValidateNormalizeFileName(encoding.GetString(header._fileName)); header.Validate(); return(header); }
internal static ZipIOCentralDirectoryFileHeader ParseRecord(BinaryReader reader, Encoding encoding) { ZipIOCentralDirectoryFileHeader header = new ZipIOCentralDirectoryFileHeader(encoding); header._signature = reader.ReadUInt32(); header._versionMadeBy = reader.ReadUInt16(); header._versionNeededToExtract = reader.ReadUInt16(); header._generalPurposeBitFlag = reader.ReadUInt16(); header._compressionMethod = reader.ReadUInt16(); header._lastModFileDateTime = reader.ReadUInt32(); header._crc32 = reader.ReadUInt32(); header._compressedSize = reader.ReadUInt32(); header._uncompressedSize = reader.ReadUInt32(); header._fileNameLength = reader.ReadUInt16(); header._extraFieldLength = reader.ReadUInt16(); header._fileCommentLength = reader.ReadUInt16(); header._diskNumberStart = reader.ReadUInt16(); header._internalFileAttributes = reader.ReadUInt16(); header._externalFileAttributes = reader.ReadUInt32(); header._relativeOffsetOfLocalHeader = reader.ReadUInt32(); header._fileName = reader.ReadBytes(header._fileNameLength); ZipIOZip64ExtraFieldUsage none = ZipIOZip64ExtraFieldUsage.None; if (header._versionNeededToExtract >= 0x2d) { if (header._compressedSize == uint.MaxValue) { none |= ZipIOZip64ExtraFieldUsage.CompressedSize; } if (header._uncompressedSize == uint.MaxValue) { none |= ZipIOZip64ExtraFieldUsage.UncompressedSize; } if (header._relativeOffsetOfLocalHeader == uint.MaxValue) { none |= ZipIOZip64ExtraFieldUsage.OffsetOfLocalHeader; } if (header._diskNumberStart == 0xffff) { none |= ZipIOZip64ExtraFieldUsage.DiskNumber; } } header._extraField = ZipIOExtraField.ParseRecord(reader, none, header._extraFieldLength); header._fileComment = reader.ReadBytes(header._fileCommentLength); header._stringFileName = ZipIOBlockManager.ValidateNormalizeFileName(encoding.GetString(header._fileName)); header.Validate(); return(header); }