Allow patches to ignore filesize so a partial file can be patched.
This commit is contained in:
parent
b81f25a38f
commit
0aa4d6403d
|
@ -91,6 +91,8 @@ instead patch the reverse of each patch. A binary that was patched using `Binary
|
|||
can be reverted back to the original format by calling `BinaryDiff.patch` again with
|
||||
the "reverse" argument set to True. Note that the only restriction to this is if any of
|
||||
the patches include wildcards then the resulting patched binary cannot be reversed.
|
||||
If you pass in the optional boolean keyword argument "ignore_size_differences" then the
|
||||
"File Size" comment will be ignored.
|
||||
|
||||
### Patch Format
|
||||
|
||||
|
|
|
@ -166,14 +166,17 @@ class BinaryDiff:
|
|||
patchlines: List[str],
|
||||
*,
|
||||
reverse: bool = False,
|
||||
ignore_size_differences: bool = False,
|
||||
) -> bytes:
|
||||
# First, grab the differences
|
||||
if not ignore_size_differences:
|
||||
file_size = BinaryDiff.size(patchlines)
|
||||
if file_size is not None and file_size != len(binary):
|
||||
raise BinaryDiffException(
|
||||
f"Patch is for binary of size {file_size} but binary is {len(binary)} "
|
||||
f"bytes long!"
|
||||
)
|
||||
|
||||
differences: List[Tuple[int, Optional[bytes], bytes]] = sorted(
|
||||
BinaryDiff._gather_differences(patchlines, reverse),
|
||||
key=lambda diff: diff[0],
|
||||
|
|
2
setup.py
2
setup.py
|
@ -8,7 +8,7 @@ with open(os.path.join("arcadeutils", "README.md"), "r", encoding="utf-8") as fh
|
|||
|
||||
setup(
|
||||
name='arcadeutils',
|
||||
version='0.1.2',
|
||||
version='0.1.3',
|
||||
description='Collection of utilities written in Python for working with various arcade binaries.',
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
|
|
Loading…
Reference in New Issue