diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-11 07:58:18 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-11 07:58:18 +0000 |
commit | 55244c8fd50dfda9c7c434cd05fc6280204447dd (patch) | |
tree | 8780ed2bcb2f16c537502b55d09caac82386f754 /src/bzip2.cpp | |
parent | 408aca47fd423e7c4c38665b892a13c1c9fb1e9a (diff) | |
download | libbu++-55244c8fd50dfda9c7c434cd05fc6280204447dd.tar.gz libbu++-55244c8fd50dfda9c7c434cd05fc6280204447dd.tar.bz2 libbu++-55244c8fd50dfda9c7c434cd05fc6280204447dd.tar.xz libbu++-55244c8fd50dfda9c7c434cd05fc6280204447dd.zip |
Wow that was a stupid bug. OK, decompression is working really well, and it
corrects the underlying stream's position if it can seek, otherwise you just
lose data (for now).
Diffstat (limited to '')
-rw-r--r-- | src/bzip2.cpp | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/bzip2.cpp b/src/bzip2.cpp index 6bb1429..d3f237a 100644 --- a/src/bzip2.cpp +++ b/src/bzip2.cpp | |||
@@ -64,13 +64,9 @@ void Bu::BZip2::bzError( int code ) | |||
64 | switch( code ) | 64 | switch( code ) |
65 | { | 65 | { |
66 | case BZ_OK: | 66 | case BZ_OK: |
67 | printf("<BZ_OK>\n"); return; | ||
68 | case BZ_RUN_OK: | 67 | case BZ_RUN_OK: |
69 | printf("<BZ_RUN_OK>\n"); return; | ||
70 | case BZ_FLUSH_OK: | 68 | case BZ_FLUSH_OK: |
71 | printf("<BZ_FLUSH_OK>\n"); return; | ||
72 | case BZ_FINISH_OK: | 69 | case BZ_FINISH_OK: |
73 | printf("<BZ_FINISH_OK>\n"); return; | ||
74 | return; | 70 | return; |
75 | 71 | ||
76 | case BZ_CONFIG_ERROR: | 72 | case BZ_CONFIG_ERROR: |
@@ -120,19 +116,16 @@ size_t Bu::BZip2::read( void *pData, size_t nBytes ) | |||
120 | 116 | ||
121 | int nRead = 0; | 117 | int nRead = 0; |
122 | int nReadTotal = bzState.total_out_lo32; | 118 | int nReadTotal = bzState.total_out_lo32; |
119 | bzState.next_out = (char *)pData; | ||
120 | bzState.avail_out = nBytes; | ||
123 | for(;;) | 121 | for(;;) |
124 | { | 122 | { |
125 | bzState.next_out = (char *)pData; | ||
126 | bzState.avail_out = nBytes; | ||
127 | printf(" (pre) in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); | ||
128 | int ret = BZ2_bzDecompress( &bzState ); | 123 | int ret = BZ2_bzDecompress( &bzState ); |
129 | printf("(post) in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); | ||
130 | 124 | ||
131 | nReadTotal += nRead-bzState.avail_out; | 125 | nReadTotal += nRead-bzState.avail_out; |
132 | 126 | ||
133 | if( ret == BZ_STREAM_END ) | 127 | if( ret == BZ_STREAM_END ) |
134 | { | 128 | { |
135 | printf("<BZ_STREAM_END>\n"); | ||
136 | if( bzState.avail_in > 0 ) | 129 | if( bzState.avail_in > 0 ) |
137 | { | 130 | { |
138 | if( rNext.canSeek() ) | 131 | if( rNext.canSeek() ) |
@@ -146,8 +139,6 @@ size_t Bu::BZip2::read( void *pData, size_t nBytes ) | |||
146 | 139 | ||
147 | if( bzState.avail_out ) | 140 | if( bzState.avail_out ) |
148 | { | 141 | { |
149 | printf("Still more to fill, in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); | ||
150 | |||
151 | if( bzState.avail_in == 0 ) | 142 | if( bzState.avail_in == 0 ) |
152 | { | 143 | { |
153 | nRead = rNext.read( pBuf, nBufSize ); | 144 | nRead = rNext.read( pBuf, nBufSize ); |