func (a *archive15) readBlockHeader() (*blockHeader15, error) {
	var err error
	b := a.buf[:7]
	r := io.Reader(a.v)
	if a.encrypted {
		salt := a.buf[:saltSize]
		_, err = io.ReadFull(r, salt)
		if err != nil {
			return nil, err
		}
		key, iv := a.getKeys(salt)
		r = newAesDecryptReader(r, key, iv)
		err = readFull(r, b)
	} else {
		_, err = io.ReadFull(r, b)
	}
	if err != nil {
		return nil, err
	}

	crc := b.uint16()
	hash := crc32.NewIEEE()
	hash.Write(b)
	h := new(blockHeader15)
	h.htype = b.byte()
	h.flags = b.uint16()
	size := b.uint16()
	if size < 7 {
		return nil, errCorruptHeader
	}
	size -= 7
	if int(size) > cap(a.buf) {
		a.buf = readBuf(make([]byte, size))
	}
	h.data = a.buf[:size]
	if err := readFull(r, h.data); err != nil {
		return nil, err
	}
	hash.Write(h.data)
	if crc != uint16(hash.Sum32()) {
		return nil, errBadHeaderCrc
	}
	if h.flags&blockHasData > 0 {
		if len(h.data) < 4 {
			return nil, errCorruptHeader
		}
		h.dataSize = int64(h.data.uint32())
	}
	if (h.htype == blockService || h.htype == blockFile) && h.flags&fileLargeData > 0 {
		if len(h.data) < 25 {
			return nil, errCorruptHeader
		}
		b := h.data[21:25]
		h.dataSize |= int64(b.uint32()) << 32
	}
	return h, nil
}
func (a *archive15) readBlockHeader() (*blockHeader15, error) {
	var err error
	b := a.buf[:7]
	r := io.Reader(a.v)
	if a.encrypted {
		salt := a.buf[:saltSize]
		_, err = io.ReadFull(r, salt)
		if err != nil {
			return nil, err
		}
		key, iv := a.getKeys(salt)
		r = newAesDecryptReader(r, key, iv)
		err = readFull(r, b)
	} else {
		_, err = io.ReadFull(r, b)
	}
	if err != nil {
		return nil, err
	}

	crc := b.uint16()
	hash := crc32.NewIEEE()
	hash.Write(b)
	h := new(blockHeader15)
	h.htype = b.byte()
	h.flags = b.uint16()
	size := b.uint16()
	if size < 7 {
		return nil, errCorruptHeader
	}
	size -= 7
	if int(size) > cap(a.buf) {
		a.buf = readBuf(make([]byte, size))
	}
	h.data = a.buf[:size]
	if err := readFull(r, h.data); err != nil {
		return nil, err
	}
	hash.Write(h.data)
	if crc != uint16(hash.Sum32()) {
		return nil, errBadHeaderCrc
	}
	if h.flags&blockHasData > 0 {
		if len(h.data) < 4 {
			return nil, errCorruptHeader
		}
		h.dataSize = int64(h.data.uint32())
	}
	if (h.htype == blockService || h.htype == blockFile) && h.flags&fileLargeData > 0 {
		if len(h.data) < 25 {
			return nil, errCorruptHeader
		}
		b := h.data[21:25]
		h.dataSize |= int64(b.uint32()) << 32
	}
	return h, nil
}
func ( a * archive15 ) readBlockHeader ( ) ( * blockHeader15 , error ) { var err error b := a . buf [ : 7 ] r := io . Reader ( a . v ) if a . encrypted { salt := a . buf [ : saltSize ] _ , err = io . ReadFull ( r , salt ) if err != nil { return nil , err } key , iv := a . getKeys ( salt ) r = newAesDecryptReader ( r , key , iv ) err = readFull ( r , b ) } else { _ , err = io . ReadFull ( r , b ) } if err != nil { return nil , err } crc := b . uint16 ( ) hash := crc32 . NewIEEE ( ) hash . Write ( b ) h := new ( blockHeader15 ) h . htype = b . byte ( ) h . flags = b . uint16 ( ) size := b . uint16 ( ) if size < 7 { return nil , errCorruptHeader } size -= 7 if int ( size ) > cap ( a . buf ) { a . buf = readBuf ( make ( [ ] byte , size ) ) } h . data = a . buf [ : size ] if err := readFull ( r , h . data ) ; err != nil { return nil , err } hash . Write ( h . data ) if crc != uint16 ( hash . Sum32 ( ) ) { return nil , errBadHeaderCrc } if h . flags & blockHasData > 0 { if len ( h . data ) < 4 { return nil , errCorruptHeader } h . dataSize = int64 ( h . data . uint32 ( ) ) } if ( h . htype == blockService || h . htype == blockFile ) && h . flags & fileLargeData > 0 { if len ( h . data ) < 25 { return nil , errCorruptHeader } b := h . data [ 21 : 25 ] h . dataSize |= int64 ( b . uint32 ( ) ) << 32 } return h , nil }
// readBlockHeader returns the next block header in the archive.
// It will return io.EOF if there were no bytes read.
readBlockHeader returns the next block header in the archive . It will return io . EOF if there were no bytes read .