From 5391b3569f63ad8cd51c26e64994062b49fc8e5f Mon Sep 17 00:00:00 2001 From: kichik Date: Mon, 5 Jan 2004 14:22:14 +0000 Subject: [PATCH] fixed non solid compression using bzip2 or lzma git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3359 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/cbzip2.h | 8 +++++++- Source/clzma.h | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/cbzip2.h b/Source/cbzip2.h index 32e313ba..bd70c948 100644 --- a/Source/cbzip2.h +++ b/Source/cbzip2.h @@ -7,6 +7,7 @@ class CBzip2 : public ICompressor { public: int Init(int level) { + last_ret = !BZ_STREAM_END; stream = new bz_stream; if (!stream) return BZ_MEM_ERROR; return BZ2_bzCompressInit(stream, level, 0, 30); @@ -19,7 +20,11 @@ class CBzip2 : public ICompressor { } int Compress(BOOL finish) { - return BZ2_bzCompress(stream, finish?BZ_FINISH:0); + // act like zlib when it comes to stream ending + if (last_ret == BZ_STREAM_END) + return BZ_STREAM_END; + last_ret = BZ2_bzCompress(stream, finish?BZ_FINISH:0); + return last_ret; } void SetNextIn(char *in, unsigned int size) { @@ -50,6 +55,7 @@ class CBzip2 : public ICompressor { private: bz_stream *stream; + int last_ret; }; #endif \ No newline at end of file diff --git a/Source/clzma.h b/Source/clzma.h index 78aada53..5a7a6d22 100644 --- a/Source/clzma.h +++ b/Source/clzma.h @@ -159,7 +159,13 @@ public: int Compress(BOOL flush) { if (compressor_finished) - return -1; + { + // act like zlib when it comes to stream ending + if (flush) + return C_OK; + else + return -1; + } if (!hCompressionThread) {