Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does writeDAT need to determine the file size to ensure that zip32 or zip64 is used? #9

Open
abo-H opened this issue Sep 19, 2024 · 2 comments

Comments

@abo-H
Copy link

abo-H commented Sep 19, 2024

I am confused. In Zip64Impl, when the zip compression version number is 4.5, if the zip64 extension does not exist and the compressed file size is less than 4GB, in this method int writeDAT(Entry entry) throws IOException, 8 bytes will be used to represent the file size.
Does this comply with the zip standard specification? I did not see in the zip standard document that zip4.5 version must use the zip64 format Data Descriptor extension.
In other words, is it necessary to make a judgment here? To use the zip32 format or zip64 format Data Descriptor?

    /**
     * Write Data Descriptor
     */
    int writeDAT(Entry entry) throws IOException {
        written = 0;
        writeInt(PK0708);                        // data descriptor signature "PK\007\008"
        writeInt(entry.crc);                     // crc-32
        writeLong(entry.compressedSize);         // compressed size (zip64)
        writeLong(entry.size);                   // uncompressed size (zip64)
        return written;
    }

The reason I'm confused by this is that when there is only version 4.5 in a zip, the file size is less than 4GB and there is no zip64 extension.
Other parsing libraries cannot parse the data descripte area correctly (treating it as zip32 or zip64?), and I'm not sure if this is a problem with the other zip parsing libraries or writeDAT's problem?

@rzymek
Copy link
Owner

rzymek commented Sep 19, 2024

I don't remember the details, as I did write this 5 years ago. Keep in mind that this is a zip64 implementation made specifically for MS Excel to understand. It's not meant to be a general Zip64 library. Zip64 spec is quite vague, as far as I remember and this implementation strives to produce xlsx (zipped dirs with xmls) that are very similar to what MS Excel produces.

@abo-H
Copy link
Author

abo-H commented Sep 20, 2024

I don't remember the details, as I did write this 5 years ago. Keep in mind that this is a zip64 implementation made specifically for MS Excel to understand. It's not meant to be a general Zip64 library. Zip64 spec is quite vague, as far as I remember and this implementation strives to produce xlsx (zipped dirs with xmls) that are very similar to what MS Excel produces.

Yes, the zip64 standard is indeed vague, but it looks like MS Excel does it this way. It sounds crazy to have different zip implementations compatible with different zip parsing libraries.🤯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants