7zip produces different output from identical input

心已入冬 提交于 2019-12-24 12:13:25

问题


I'm using command line 7zip to zip up the contents of a folder (in Windows) thus:

7za a myzip.zip * -tzip -r

I've discovered that running exactly the same command line twice will produce two different ZIP files - they've got the same size but if you run a binary compare (ie fc /b file1.zip file2.zip) they are different. To complicate matters it seems that if you make the two zips in rapid succession then they are the same. But if you do them on different days or separated by a few hours they are not.

I presume that there's a date/time stamp in the ZIP file somewhere but I can't find anything on the 7zip site to confirm that.

Assuming I'm right does anyone know how to suppress the date/time? Or is something else causing the binaries to be different?


回答1:


7-zip has the switch -m with parameter tc which has value on by default if not specified on command line.

With -mtc=on all 3 dates of a file stored on an NTFS partition are stored in the archive:

  • the last modification time,
  • the creation time, and also
  • the last access time.

See in help of 7-zip the page with title -m (Set compression Method) switch.

The last access time of the files is most likely responsible for the differences between the archive files.

You have to append -mtc=off to avoid storage of the NTFS timestamps in archive file.



来源:https://stackoverflow.com/questions/27136783/7zip-produces-different-output-from-identical-input

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!