diff --git a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp index 1ee7e22f..cc14d16f 100644 --- a/CPP/7zip/Archive/Zip/ZipAddCommon.cpp +++ b/CPP/7zip/Archive/Zip/ZipAddCommon.cpp @@ -18,6 +18,7 @@ #include "../../Compress/LzmaEncoder.h" #include "../../Compress/PpmdZip.h" #include "../../Compress/XzEncoder.h" +#include "../../Compress/ZstdEncoder.h" #include "../Common/InStreamWithCRC.h" @@ -179,6 +180,7 @@ HRESULT CAddCommon::Set_Pre_CompressionResult(bool inSeqMode, bool outSeqMode, U case NCompressionMethod::kXz : ver = NCompressionMethod::kExtractVersion_Xz; break; case NCompressionMethod::kPPMd : ver = NCompressionMethod::kExtractVersion_PPMd; break; case NCompressionMethod::kBZip2: ver = NCompressionMethod::kExtractVersion_BZip2; break; + case NCompressionMethod::kZstd: ver = NCompressionMethod::kExtractVersion_Zstd; break; case NCompressionMethod::kLZMA : { ver = NCompressionMethod::kExtractVersion_LZMA; @@ -356,6 +358,12 @@ HRESULT CAddCommon::Compress( _lzmaEncoder = new CLzmaEncoder(); _compressEncoder = _lzmaEncoder; } + else if (method == NCompressionMethod::kZstd) + { + _compressExtractVersion = NCompressionMethod::kExtractVersion_Zstd; + NCompress::NZSTD::CEncoder *encoder = new NCompress::NZSTD::CEncoder(); + _compressEncoder = encoder; + } else if (method == NCompressionMethod::kXz) { _compressExtractVersion = NCompressionMethod::kExtractVersion_Xz; diff --git a/CPP/7zip/Archive/Zip/ZipHandler.cpp b/CPP/7zip/Archive/Zip/ZipHandler.cpp index a4794f51..6c029c05 100644 --- a/CPP/7zip/Archive/Zip/ZipHandler.cpp +++ b/CPP/7zip/Archive/Zip/ZipHandler.cpp @@ -23,6 +23,7 @@ #include "../../Compress/PpmdZip.h" #include "../../Compress/ShrinkDecoder.h" #include "../../Compress/XzDecoder.h" +#include "../../Compress/ZstdDecoder.h" #include "../../Crypto/WzAes.h" #include "../../Crypto/ZipCrypto.h" @@ -746,6 +747,32 @@ STDMETHODIMP CHandler::Close() return S_OK; } +class CZstdDecoder: + public ICompressCoder, + public CMyUnknownImp +{ + NCompress::NZSTD::CDecoder *DecoderSpec; + CMyComPtr Decoder; +public: + CZstdDecoder(); + STDMETHOD(Code)(ISequentialInStream *inStream, ISequentialOutStream *outStream, + const UInt64 *inSize, const UInt64 *outSize, ICompressProgressInfo *progress); + + MY_UNKNOWN_IMP +}; + +CZstdDecoder::CZstdDecoder() +{ + DecoderSpec = new NCompress::NZSTD::CDecoder; + Decoder = DecoderSpec; +} + +HRESULT CZstdDecoder::Code(ISequentialInStream *inStream, ISequentialOutStream *outStream, + const UInt64 * /* inSize */, const UInt64 *outSize, ICompressProgressInfo *progress) +{ + return Decoder->Code(inStream, outStream, NULL, outSize, progress); +} + class CLzmaDecoder: public ICompressCoder, @@ -1059,6 +1086,8 @@ HRESULT CZipDecoder::Decode( lzmaDecoderSpec = new CLzmaDecoder; mi.Coder = lzmaDecoderSpec; } + else if (id ==NFileHeader::NCompressionMethod::kZstd) + mi.Coder = new CZstdDecoder(); else if (id == NFileHeader::NCompressionMethod::kXz) mi.Coder = new NCompress::NXz::CComDecoder; else if (id == NFileHeader::NCompressionMethod::kPPMd) diff --git a/CPP/7zip/Archive/Zip/ZipHeader.h b/CPP/7zip/Archive/Zip/ZipHeader.h index 5e6f00e4..f2e3ddc0 100644 --- a/CPP/7zip/Archive/Zip/ZipHeader.h +++ b/CPP/7zip/Archive/Zip/ZipHeader.h @@ -57,6 +57,7 @@ namespace NFileHeader kTerse = 18, kLz77 = 19, + kZstd = 93, kXz = 95, kJpeg = 96, kWavPack = 97, @@ -77,6 +78,7 @@ namespace NFileHeader const Byte kExtractVersion_LZMA = 63; const Byte kExtractVersion_PPMd = 63; const Byte kExtractVersion_Xz = 20; // test it + const Byte kExtractVersion_Zstd = 20; // WinZip mark it } namespace NExtraID