//public byte[] extraField; //public byte[] comment; public static PakCentralDirFile Read(BinaryReader br) { var result = new PakCentralDirFile(); result.signature1 = br.ReadUInt16(); result.signature2 = br.ReadUInt16(); result.createVersion = br.ReadUInt16(); result.extractVersion = br.ReadUInt16(); result.flags = br.ReadUInt16(); result.compressionMethod = br.ReadUInt16(); result.time = br.ReadUInt16(); result.date = br.ReadUInt16(); result.crc = br.ReadUInt32(); result.compressedSize = br.ReadUInt32(); result.uncompressedSize = br.ReadUInt32(); result.filenameLength = br.ReadUInt16(); result.extraFieldLength = br.ReadUInt16(); result.fileCommentLength = br.ReadUInt16(); result.diskNumStart = br.ReadUInt16(); result.internalFileAttr = br.ReadUInt16(); result.externalFileAttr = br.ReadUInt32(); result.localHeaderOffset = br.ReadUInt32(); result.filename = PakUtil.ReadFilename(br, result.filenameLength); if (result.signature1 == PakConstants.PAK_SIGNATURE1 && result.signature2 == PakConstants.PAK_SIGNATURE2_DIR) { result.isAionFormat = true; } else { if (result.signature1 != PakConstants.ZIP_SIGNATURE1 || result.signature2 != PakConstants.ZIP_SIGNATURE2_DIR) { throw new InvalidOperationException("bad central dir signature"); } // zipformat = true } if (result.extraFieldLength != 0) { var b = br.ReadBytes(result.extraFieldLength); // throw new InvalidOperationException("extra field not supported"); } if (result.fileCommentLength != 0) { throw new InvalidOperationException("file comment not supported"); } if (result.diskNumStart != 0) { throw new InvalidOperationException("disk num not supported"); } return(result); }
public EncryptedAionPakReader(Stream stream, PakCentralDirFile dirfile) { m_underlying = stream; m_startPosition = stream.Position; m_dirfile = dirfile; if (!dirfile.isAionFormat) { throw new InvalidOperationException("zip stream is not encrypted!"); } }