Exemplo n.º 1
0
 public static ArchiveHeader Create()
 {
     return(new ArchiveHeader()
     {
         Signature = PackSignature,
         Version = 1,
         Reserved = new byte[ReservedSectionSize],
         DataHeader = DataHeader.Create()
     });
 }
Exemplo n.º 2
0
        public static DataHeader ReadFrom(BinaryReader binaryReader)
        {
            var ret = new DataHeader
            {
                //Unknown1 = binaryReader.ReadUInt64(),
                FileSize         = binaryReader.ReadUInt64(),
                Reserved         = binaryReader.ReadUInt64(),
                BlockTableOffset = binaryReader.ReadUInt64(),
                BlockCount       = binaryReader.ReadInt64(),
                RootBlockIndex   = binaryReader.ReadInt64(),
                ReverseSeekGuard = binaryReader.ReadUInt64()
            };

            return(ret);
        }
Exemplo n.º 3
0
        public static ArchiveHeader ReadFrom(Stream stream)
        {
            var ret = new ArchiveHeader();

            using (var binaryReader = new BinaryReader(stream, Encoding.UTF8, true))
            {
                ret.Signature  = binaryReader.ReadUInt32();
                ret.Version    = binaryReader.ReadUInt32();
                ret.Reserved   = binaryReader.ReadBytes(ReservedSectionSize);
                ret.DataHeader = DataHeader.ReadFrom(binaryReader);
            }
            if (ret.Signature != PackSignature)
            {
                throw new InvalidDataException($"File header value {ret.Signature:X4} does not match expected {PackSignature:X4}");
            }

            return(ret);
        }