Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion UnityPy/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,11 @@ def load_zip_file(self, value):
def save(self, pack="none", out_path="output"):
"""Saves all changed assets.
Mark assets as changed using `.mark_changed()`.
pack = "none" (default) or "lz4"

``pack`` is forwarded as ``packer`` to each file's ``save()``.
Supported values depend on the file type, for example:
BundleFile - "none", "lz4", "lz4hc", "lzma", "original"
WebFile - "none", "gzip", "brotli"
"""
Comment thread
com55 marked this conversation as resolved.
for fname, fitem in self.files.items():
if getattr(fitem, "is_changed", False):
Expand Down
9 changes: 7 additions & 2 deletions UnityPy/files/BundleFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ def save(self, packer=None):

packer:
can be either one of the following strings
or tuple consisting of (block_info_flag, data_flag)
or tuple consisting of (data_flag, block_info_flag)
allowed strings:
none - no compression, default, safest bet
lz4 - lz4 compression
lz4hc - lz4hc compression
lzma - lzma compression
original - uses the original flags
"""
# file_header
Expand Down Expand Up @@ -227,6 +229,8 @@ def save(self, packer=None):
)
elif packer == "lz4":
self.save_fs(writer, data_flag=194, block_info_flag=2)
elif packer == "lz4hc":
self.save_fs(writer, data_flag=195, block_info_flag=3)
elif packer == "lzma":
self.save_fs(writer, data_flag=65, block_info_flag=1)
elif isinstance(packer, tuple):
Expand All @@ -242,12 +246,13 @@ def save_fs(self, writer: EndianBinaryWriter, data_flag: int, block_info_flag: i

# 0b1000000 / 0b11000000 | 64 / 192 - uncompressed
# 0b11000010 | 194 - lz4
# 0b11000011 | 195 - lz4hc
# block_info_flag

# 0 / 0b1000000 | 0 / 64 - uncompressed
# 0b1 | 1 - lzma
# 0b10 | 2 - lz4
# 0b11 | 3 - lz4hc [not implemented]
# 0b11 | 3 - lz4hc
# 0b100 | 4 - lzham [not implemented]
# data_flag

Expand Down