Delphi TZip failing if archive contains > 64k files

Viewed 165

I just hit what appears to be an annoying limitation in Delphi.

My archive has 117,898 files in it (they're all 256x256 JPEG images so stored without ZIP compression - ZIPs just a delivery mechanism)

Anyway, I just moved up from my previous ZIP which had 24,989 images to the new one and it stops at 65536 files (i.e. index = 65535) then Range errors on me.

It, therefore appears that TZip is 16 bit (or I'm doing something emensely stupid)

I just discovered that Delphi 11 has 64 bit support - but that's also limited to 64k files

3 Answers

That is not an annoying Delphi limitation, but a limitation of the ZIP specification as can be seen here: APPNOTE.TXT

In section 4.3.16 the total number of entries in the central directory has only 2 bytes.

That is not an annoying Delphi limitation, but a limitation of the ZIP specification as can be seen here: APPNOTE.TXT

In section 4.3.16 the total number of entries in the central directory has only 2 bytes.

In the original version of the Zip spec there is indeed a limitation of 2 bytes for the number of files in the zip archive, but that has been superseded for a very long time. Below if from APPNOTE.TXT version 6.3.9

   4.4.21 total number of entries in the central dir on 
          this disk: (2 bytes)
 
      The number of central directory entries on this disk.
      If an archive is in ZIP64 format and the value in 
      this field is 0xFFFF, the size will be in the 
      corresponding 8 byte zip64 end of central 
      directory field.

If Delphi TZip supports the Zip64 spec, it should be able to store more than 64k files. Given your experience I suspect it doesn't

[EDIT]

The link provided by Reny Lebueu regarding the update to TZipFile, here, says this about support for Zip64

RTL: TZipFile
... We added support for Zip64 and ... works with files larger in size than 4 GB.

While it does mention support for Zip64, it doesn't explicitly mention support for having more than 64k files.

I wrote a little test program that creates 70,000 1 byte files in a zip file. Delphi 11.2 successfully creates the 70,000 files in the zip file. In the test program I also made it read the file that had been created. It successfully read the 70,000 1 byte files.

I had a look at the differences in system.zip for Delphi 11 and while there are some changes... I don't think it would affect working with large numbers of files in the zip.

Related