I have following code in python:
>>> import zipfile
>>> zip = zipfile.ZipFile('abc.zip', 'w')
>>> zip.writestr('myfile', 'This is sample text')
>>> zip.writestr('myfile', 'This is sample text')
>>> zip.close()
This creates an archive with two files having exactly same name and path.
Why is this?
This is allowed by Zip and some other archive formats, like Tar, and even addressed by the Python API:
Note: The
open()
,read()
andextract()
methods can take a filename or aZipInfo
object. You will appreciate this when trying to read a ZIP file that contains members with duplicate names.