Last active
April 11, 2024 19:19
-
-
Save obfusk/25a2c5c43734b80465980a38af8c31df to your computer and use it in GitHub Desktop.
create a ZIP file with two CD entries pointing to the same file
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
#!/usr/bin/python3 | |
import sys | |
import zipfile | |
# Usage: zipdup.py ZIPFILE ENTRY_NAME ENTRY_DATA | |
zfile, zentry, data = sys.argv[1:] | |
with zipfile.ZipFile(zfile, "w") as zf: | |
info = zipfile.ZipInfo(filename=zentry) | |
zf.writestr(info, data) | |
zf.filelist.append(info) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment