Skip to content

Commit

Permalink
📝 small improve
Browse files Browse the repository at this point in the history
  • Loading branch information
CrescentApricot committed Mar 4, 2019
1 parent dc1f0a3 commit c7fb8d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions lz4unipy/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,16 @@
def compress(data: bytes) -> bytes:
buf = lz4.block.compress(data, mode="high_compression")[4:]
with BytesIO() as bio:
bio.write(pack('i', 100))
bio.write(b'd\x00\x00\x00')
bio.write(pack('i', len(data)))
bio.write(pack('i', len(buf)))
bio.write(pack('i', 1))
bio.write(b'\x01\x00\x00\x00')
bio.write(buf)
return bio.getvalue()


def decompress(data: bytes) -> bytes:
with BytesIO() as bio:
bio.write(data[4:8])
bio.write(data[16:])
stream = bio.getvalue()
return lz4.block.decompress(stream)
return lz4.block.decompress(data[16:], uncompressed_size=unpack("i", data[4:8])[0])


def is_compressed(data: bytes) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='lz4unipy',
version='2.0.0',
version='2.0.1',
description='unity3d compatible lz4 (un)compress tool working on Python3.',
long_description=long_description,
author='CrescentApricot',
Expand Down

0 comments on commit c7fb8d9

Please sign in to comment.