# footer
FOOTER = '8s8I4s'
FOOTER_SIZE = struct.calcsize(FOOTER)
if file_size < FOOTER_SIZE:
raise ValueError('Input file size is too small: %d' % file_size)
f.seek(-FOOTER_SIZE, os.SEEK_END)
data = f.read(FOOTER_SIZE)
reserved, meta_data_crc32, meta_data_size, info_crc32, num_files, names_size_compressed, names_size_original, files_table_size, files_table_crc32, marker = struct.unpack(FOOTER, data)
if marker != DVPK_MARKER:
raise ValueError('Input file footer marker is invalid: %s' % binascii.hexlify(marker))
In [24]: struct.pack('8s8I4s', b'stroka12', 1, 2, 3, 4, 5, 6, 7, 8, b'eshe')
Out[24]: b'stroka12\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00eshe'
In [26]: x = struct.pack('8s8I4s', b'stroka12', 1, 2, 3, 4, 5, 6, 7, 8, b'eshe')
In [27]: struct.unpack('8s8I4s', x)
Out[27]: (b'stroka12', 1, 2, 3, 4, 5, 6, 7, 8, b'eshe')