summaryrefslogtreecommitdiff
path: root/src/bzip2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/bzip2.cpp')
-rw-r--r--src/bzip2.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/bzip2.cpp b/src/bzip2.cpp
index 0a56f83..7f6e45e 100644
--- a/src/bzip2.cpp
+++ b/src/bzip2.cpp
@@ -12,7 +12,8 @@ using namespace Bu;
12 12
13Bu::BZip2::BZip2( Bu::Stream &rNext, int nCompression ) : 13Bu::BZip2::BZip2( Bu::Stream &rNext, int nCompression ) :
14 Bu::Filter( rNext ), 14 Bu::Filter( rNext ),
15 nCompression( nCompression ) 15 nCompression( nCompression ),
16 sTotalOut( 0 )
16{ 17{
17 TRACE( nCompression ); 18 TRACE( nCompression );
18 start(); 19 start();
@@ -50,7 +51,7 @@ size_t Bu::BZip2::stop()
50 } 51 }
51 else 52 else
52 { 53 {
53 size_t sTotal = 0; 54// size_t sTotal = 0;
54 for(;;) 55 for(;;)
55 { 56 {
56 bzState.next_in = NULL; 57 bzState.next_in = NULL;
@@ -60,7 +61,7 @@ size_t Bu::BZip2::stop()
60 int res = BZ2_bzCompress( &bzState, BZ_FINISH ); 61 int res = BZ2_bzCompress( &bzState, BZ_FINISH );
61 if( bzState.avail_out < nBufSize ) 62 if( bzState.avail_out < nBufSize )
62 { 63 {
63 sTotal += rNext.write( pBuf, nBufSize-bzState.avail_out ); 64 sTotalOut += rNext.write( pBuf, nBufSize-bzState.avail_out );
64 } 65 }
65 if( res == BZ_STREAM_END ) 66 if( res == BZ_STREAM_END )
66 break; 67 break;
@@ -68,7 +69,7 @@ size_t Bu::BZip2::stop()
68 BZ2_bzCompressEnd( &bzState ); 69 BZ2_bzCompressEnd( &bzState );
69 delete[] pBuf; 70 delete[] pBuf;
70 pBuf = NULL; 71 pBuf = NULL;
71 return sTotal; 72 return sTotalOut;
72 } 73 }
73 } 74 }
74 return 0; 75 return 0;
@@ -182,7 +183,7 @@ size_t Bu::BZip2::write( const void *pData, size_t nBytes )
182 if( bReading == true ) 183 if( bReading == true )
183 throw ExceptionBase("This bzip2 filter is in reading mode, you can't write."); 184 throw ExceptionBase("This bzip2 filter is in reading mode, you can't write.");
184 185
185 size_t sTotalOut = 0; 186// size_t sTotalOut = 0;
186 bzState.next_in = (char *)pData; 187 bzState.next_in = (char *)pData;
187 bzState.avail_in = nBytes; 188 bzState.avail_in = nBytes;
188 for(;;) 189 for(;;)
@@ -209,3 +210,8 @@ bool Bu::BZip2::isOpen()
209 return (bzState.state != NULL); 210 return (bzState.state != NULL);
210} 211}
211 212
213size_t Bu::BZip2::getCompressedSize()
214{
215 return sTotalOut;
216}
217