Created
August 29, 2014 21:06
-
-
Save nl5887/9670b9af6ba5eef7839f to your computer and use it in GitHub Desktop.
LZMA add uncompressed size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mmap | |
import sys | |
with open(sys.argv[1], "r+b") as f: | |
# memory-map the file, size 0 means whole file | |
mm = mmap.mmap(f.fileno(), 0) | |
offset = int(sys.argv[2]) | |
mm[offset:] | |
f2 = sys.stdout | |
f2.write(mm[offset:offset+5]) | |
uncompressed_size = '\x00\x00\x00\x10\x00\x00\x00\x00' | |
f2.write(uncompressed_size) | |
f2.write(mm[offset+5:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment