Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uncompressed chunk padding #29

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pyaff4/aff4_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ def read(self, _):
self.bevy_length += compressedLen
return compressed_chunk
else:
# On final chunks that aren't compressed, pad if they are less than chunk_size
# so that at decompression we won't try to decompress an already decompressed chunk.
if chunkLen < self.owner.chunk_size:
padding = self.owner.chunk_size - chunkLen
chunk += b"\x00" * padding
self.bevy_index.append((self.bevy_length, self.owner.chunk_size))
self.bevy_length += self.owner.chunk_size
return chunk
Expand Down