Support zstd compression method 93 in zip archives

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
pashkoff
Junior Member
Junior Member
Posts: 3
Joined: 2022-12-30, 15:42 UTC

Support zstd compression method 93 in zip archives

Post by *pashkoff »

ZIP format had officially allocated compression method ID for Zstandard few years ago. It would be nice to support it in total commander's internal zip packer/unpacker.

I was even looking whether it would be possible to implement support myself as a plugin (or if there is any other plugin already doing it), but I was not able to find how. Seems like wcx plugin API doesn't really have a way to expose implementations of additional compression methods for use by internal zip packer. There is a plugin with zstd support, but it works with individual files and doesn't help with zip archives having zstd-compressed content.
So, alternatively, if there is no desire to support zstd compression method out of the box - I would appreciate some guidance on supporting it as a plugin.

For reference, zstd's ID is 93 according to APPNOTE.txt: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
Winzip claims its support since version 24 (released in 2019): https://www.winzip.com/en/support/compression-methods/
7-Zip-ZS has support for it as well. Although, from personal experience I can say there are some bugs in its zip handling and adding/removing files to existing files.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Support zstd compression method 93 in zip archives

Post by *ghisler(Author) »

I will consider it, thanks for the suggestion. The code seems to be under BSD license, so it should be no problem in that regard.
Author of Total Commander
https://www.ghisler.com
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Support zstd compression method 93 in zip archives

Post by *ghisler(Author) »

Do you have any sample ZIP files with zstd compression? I can't find any.
Author of Total Commander
https://www.ghisler.com
pashkoff
Junior Member
Junior Member
Posts: 3
Joined: 2022-12-30, 15:42 UTC

Re: Support zstd compression method 93 in zip archives

Post by *pashkoff »

Sure, here is one I just made with 7zip-ZS:
https://drive.google.com/file/d/1Ir8v2IslynHjsoZpTcUXrYdSGGzOKm5c/view

There is one text file inside archive. Compression method in CDR and local headers is set to 93 (0x5d). And then data stream is in zstd format accordingly. I.e., there is nothing particularly special about it.
I've had to support zip+zstd in my work project. Since we already had a custom zip handling code, adding additional compression method was as simple as invoking ZSTD_decompress() from zstd library on the data stream from zip file (of course, library also has more advanced APIs to handle explicit decompression contexts for optimized memory reuse and access, etc.)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48077
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Support zstd compression method 93 in zip archives

Post by *ghisler(Author) »

Thanks, I can confirm that it is using zstd. Neither the Windows 11 Explorer nor my 7zip copy from 2021 can unpack it.
I will check if I can integrate the library, but only for unpacking - the main advantage of ZIP is that it can be unpacked everywhere, which is a problem when using such specialized sub-formats...
Author of Total Commander
https://www.ghisler.com
pashkoff
Junior Member
Junior Member
Posts: 3
Joined: 2022-12-30, 15:42 UTC

Re: Support zstd compression method 93 in zip archives

Post by *pashkoff »

Great news, thank you! Even just decompression support would be quite helpful.
User avatar
Usher
Power Member
Power Member
Posts: 1675
Joined: 2011-03-11, 10:11 UTC

Re: Support zstd compression method 93 in zip archives

Post by *Usher »

2ghisler(Author)
7-zip opens the file if you install zstd codec available here:
https://www.tc4shell.com/en/7zip/modern7z/
Andrzej P. Wozniak
Polish subforum moderator
Post Reply