private static bool HasZip64ExtendedInformationExtraField(CentralDirectoryHeader header) { IReadOnlyList <ExtraField> extraFields; if (ExtraField.TryRead(header, out extraFields)) { return(extraFields.Any(extraField => extraField is Zip64ExtendedInformationExtraField)); } return(false); }
private static bool TryRead( byte[] extraFieldBytes, ushort extraFieldLength, bool readUncompressedFileSize, bool readCompressedFileSize, bool readRelativeOffsetOfLocalHeader, bool readDiskNumberStart, out IReadOnlyList <ExtraField> extraFields) { var fields = new List <ExtraField>(); extraFields = fields; using (var stream = new MemoryStream(extraFieldBytes)) using (var reader = new BinaryReader(stream)) { while (stream.Position < stream.Length - 1) { var headerId = reader.ReadUInt16(); var dataSize = reader.ReadUInt16(); var data = reader.ReadBytes(dataSize); ExtraField extraField; if (headerId == 0x0001) { extraField = Zip64ExtendedInformationExtraField.Read( headerId, dataSize, data, readUncompressedFileSize, readCompressedFileSize, readRelativeOffsetOfLocalHeader, readDiskNumberStart); } else { extraField = new ExtraField(headerId, dataSize, data); } fields.Add(extraField); } } return(true); }