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..6f9ccd63 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" @@ -86,7 +87,9 @@ const char * const kMethodNames1[kNumMethodNames1] = const char * const kMethodNames2[kNumMethodNames2] = { - "xz" + "zstd" + , NULL + , "xz" , "Jpeg" , "WavPack" , "PPMd" @@ -746,6 +749,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 +1088,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/ZipHandler.h b/CPP/7zip/Archive/Zip/ZipHandler.h index bee57c00..88b3eb39 100644 --- a/CPP/7zip/Archive/Zip/ZipHandler.h +++ b/CPP/7zip/Archive/Zip/ZipHandler.h @@ -16,7 +16,7 @@ namespace NArchive { namespace NZip { const unsigned kNumMethodNames1 = NFileHeader::NCompressionMethod::kLZMA + 1; -const unsigned kMethodNames2Start = NFileHeader::NCompressionMethod::kXz; +const unsigned kMethodNames2Start = NFileHeader::NCompressionMethod::kZstd; const unsigned kNumMethodNames2 = NFileHeader::NCompressionMethod::kWzAES + 1 - kMethodNames2Start; extern const char * const kMethodNames1[kNumMethodNames1]; @@ -74,7 +74,7 @@ private: m_WriteNtfsTimeExtra = true; _removeSfxBlock = false; m_ForceLocal = false; - m_ForceUtf8 = false; + m_ForceUtf8 = true; _forceCodePage = false; _specifiedCodePage = CP_OEMCP; } 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 diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp index 3cce4638..9abd4d18 100644 --- a/CPP/7zip/UI/GUI/CompressDialog.cpp +++ b/CPP/7zip/UI/GUI/CompressDialog.cpp @@ -223,7 +223,8 @@ static const EMethodID g_ZipMethods[] = kDeflate64, kBZip2, kLZMA, - kPPMdZip + kPPMdZip, + kZSTD }; static const EMethodID g_GZipMethods[] =