How does one find the start of the “Central Directory” in zip files?

后端 未结 4 1784
说谎
说谎 2021-02-05 04:20

Wikipedia has an excellent description of the ZIP file format, but the \"central directory\" structure is confusing to me. Specifically this:

This orderin

4条回答
  •  迷失自我
    2021-02-05 04:32

    I was implementing zip archive support some time ago, and I search last few kilobytes for a end of central directory signature (4 bytes). That works pretty good, until somebody will put 50kb text into comment (which is unlikely to happen. To be absolutely sure, you can search last 64kb + few bytes, since comment size is 16 bit). After that, I look up for zip64 end of central dir locator, that's easier since it has fixed structure.

提交回复
热议问题