|
|
@@ -15,7 +15,16 @@ def get_dict(fp): |
|
|
|
dictSize = struct.unpack('<I', dictSize)[0] |
|
|
|
assert dictSize >= 4, 'dict too small' |
|
|
|
assert dictSize < 100 * 1024**2, 'dict too large' |
|
|
|
d = fp.read(dictSize) |
|
|
|
ds = [] |
|
|
|
dlen = 0 |
|
|
|
while dlen < dictSize: |
|
|
|
c = fp.read(dictSize - dlen) |
|
|
|
if c is None or c == b'': # EOF |
|
|
|
break |
|
|
|
ds.append(c) |
|
|
|
dlen += len(c) |
|
|
|
d = b''.join(ds) |
|
|
|
assert len(d) == dictSize, f'could not read dict fully: expected {dictSize}, got {len(d)}' |
|
|
|
assert d.startswith(b'\x28\xB5\x2F\xFD') or d.startswith(b'\x37\xA4\x30\xEC'), 'not a valid dict' |
|
|
|
if d.startswith(b'\x28\xB5\x2F\xFD'): # Compressed dict |
|
|
|
# Decompress with unzstd |
|
|
|