On Mon, 18 Mar 2002, Christoph Behnke <[EMAIL PROTECTED]> wrote: > The zip task does not store the uncompressed file size > in the generated zip file. This is not mandatory in > zip file format but other tools like winzip are > storing the uncompressed file size in the zip file.
Sorry for taking so long to answer. When I talk about the ZIP format, I'm basing what I say on <ftp://ftp.uu.net/pub/archiving/zip/doc/appnote-iz-latest.zip>. The zip classes Ant uses take advantage of the Data Descriptor that one should use if one cannot seek the files being compressed. Java's built-in java.util.zip classes do the same BTW. If you do so, you set "bit 3 of the general purpose bit flag", which again implies >> Bit 3: If this bit is set, the fields crc-32, compressed size >> and uncompressed size are set to zero in the local >> header. The correct values are put in the data descriptor >> immediately following the compressed data. So Ant is supposed to set these fields in the local file header to 0. Ant *does* store them both in the data descriptor and in the central directory file header - the later is used as the authoritative source by InfoZip. The question that remains is, why does Ant use this feature? Well, you don't know the CRC and the compressed size before you've compressed the file. And in reality you cannot trust File.length() as it may (and will) return bad values on some OSes/JVMs - that means that you don't really know the uncompressed size before you've compressed the file either. Compressing the complete file in memory may be too expensive, so Ant's zip classes (again just like java.util.zip) directly write the data into the archive while they compress the file. As you have to write the local file header before you write the data, Ant doesn't know the size information at this point and cannot insert it. > Is there a possibility to let the ant zip taks store > the file size? It does so at two places and InfoZip based zips (like the one shipping with Linux distributions) can read it: [bodewig@bodewig jakarta-ant]$ unzip -l $ANT_HOME/lib/ant.jar Archive: /home/bodewig/ASF/jakarta/jakarta-ant/bootstrap/lib/ant.jar Length Date Time Name -------- ---- ---- ---- 0 04-03-02 15:10 META-INF/ 439 04-03-02 15:10 META-INF/MANIFEST.MF [snip] so WinZIP isn't doing as good as it could 8-) Stefan -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
