diff options
author | Mike Buland <eichlan@xagasoft.com> | 2007-06-11 07:31:52 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2007-06-11 07:31:52 +0000 |
commit | 408aca47fd423e7c4c38665b892a13c1c9fb1e9a (patch) | |
tree | 604f994d615af891c2373f0dd4ac14c22ea772f7 /src/bzip2.cpp | |
parent | 5f39066a4f561e9a94a6cc9293ab9b978ebf1f81 (diff) | |
download | libbu++-408aca47fd423e7c4c38665b892a13c1c9fb1e9a.tar.gz libbu++-408aca47fd423e7c4c38665b892a13c1c9fb1e9a.tar.bz2 libbu++-408aca47fd423e7c4c38665b892a13c1c9fb1e9a.tar.xz libbu++-408aca47fd423e7c4c38665b892a13c1c9fb1e9a.zip |
Few minor tweaks to bzip2, it reports errors now...and there's a bug in odpm
that could be in this, but it's going to be hard to tell...
Diffstat (limited to 'src/bzip2.cpp')
-rw-r--r-- | src/bzip2.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/bzip2.cpp b/src/bzip2.cpp index 5423a10..6bb1429 100644 --- a/src/bzip2.cpp +++ b/src/bzip2.cpp | |||
@@ -64,6 +64,13 @@ 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: | ||
69 | printf("<BZ_RUN_OK>\n"); return; | ||
70 | case BZ_FLUSH_OK: | ||
71 | printf("<BZ_FLUSH_OK>\n"); return; | ||
72 | case BZ_FINISH_OK: | ||
73 | printf("<BZ_FINISH_OK>\n"); return; | ||
67 | return; | 74 | return; |
68 | 75 | ||
69 | case BZ_CONFIG_ERROR: | 76 | case BZ_CONFIG_ERROR: |
@@ -117,20 +124,36 @@ size_t Bu::BZip2::read( void *pData, size_t nBytes ) | |||
117 | { | 124 | { |
118 | bzState.next_out = (char *)pData; | 125 | bzState.next_out = (char *)pData; |
119 | bzState.avail_out = nBytes; | 126 | bzState.avail_out = nBytes; |
127 | printf(" (pre) in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); | ||
120 | int ret = BZ2_bzDecompress( &bzState ); | 128 | int ret = BZ2_bzDecompress( &bzState ); |
129 | printf("(post) in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); | ||
121 | 130 | ||
122 | nReadTotal += nRead-bzState.avail_out; | 131 | nReadTotal += nRead-bzState.avail_out; |
123 | 132 | ||
124 | if( ret == BZ_STREAM_END ) | 133 | if( ret == BZ_STREAM_END ) |
125 | { | 134 | { |
135 | printf("<BZ_STREAM_END>\n"); | ||
136 | if( bzState.avail_in > 0 ) | ||
137 | { | ||
138 | if( rNext.canSeek() ) | ||
139 | { | ||
140 | rNext.seek( -bzState.avail_in ); | ||
141 | } | ||
142 | } | ||
126 | return nBytes-bzState.avail_out; | 143 | return nBytes-bzState.avail_out; |
127 | } | 144 | } |
145 | bzError( ret ); | ||
128 | 146 | ||
129 | if( bzState.avail_out ) | 147 | if( bzState.avail_out ) |
130 | { | 148 | { |
131 | nRead = rNext.read( pBuf, nBufSize ); | 149 | printf("Still more to fill, in: %db, out: %db\n", bzState.avail_in, bzState.avail_out ); |
132 | bzState.next_in = pBuf; | 150 | |
133 | bzState.avail_in = nRead; | 151 | if( bzState.avail_in == 0 ) |
152 | { | ||
153 | nRead = rNext.read( pBuf, nBufSize ); | ||
154 | bzState.next_in = pBuf; | ||
155 | bzState.avail_in = nRead; | ||
156 | } | ||
134 | } | 157 | } |
135 | else | 158 | else |
136 | { | 159 | { |
@@ -158,7 +181,7 @@ size_t Bu::BZip2::write( const void *pData, size_t nBytes ) | |||
158 | bzState.avail_out = nBufSize; | 181 | bzState.avail_out = nBufSize; |
159 | bzState.next_out = pBuf; | 182 | bzState.next_out = pBuf; |
160 | 183 | ||
161 | BZ2_bzCompress( &bzState, BZ_RUN ); | 184 | bzError( BZ2_bzCompress( &bzState, BZ_RUN ) ); |
162 | 185 | ||
163 | if( bzState.avail_out < nBufSize ) | 186 | if( bzState.avail_out < nBufSize ) |
164 | { | 187 | { |