| 121 | } |
| 122 | |
| 123 | Result<DecompressResult> Decompress(int64_t input_len, const uint8_t* input, |
| 124 | int64_t output_len, uint8_t* output) override { |
| 125 | stream_.next_in = const_cast<char*>(reinterpret_cast<const char*>(input)); |
| 126 | stream_.avail_in = static_cast<unsigned int>(std::min(input_len, kSizeLimit)); |
| 127 | stream_.next_out = reinterpret_cast<char*>(output); |
| 128 | stream_.avail_out = static_cast<unsigned int>(std::min(output_len, kSizeLimit)); |
| 129 | int ret; |
| 130 | |
| 131 | ret = BZ2_bzDecompress(&stream_); |
| 132 | if (ret == BZ_OK || ret == BZ_STREAM_END) { |
| 133 | finished_ = (ret == BZ_STREAM_END); |
| 134 | int64_t bytes_read = input_len - stream_.avail_in; |
| 135 | int64_t bytes_written = output_len - stream_.avail_out; |
| 136 | return DecompressResult{bytes_read, bytes_written, |
| 137 | (!finished_ && bytes_read == 0 && bytes_written == 0)}; |
| 138 | } else { |
| 139 | return BZ2Error("bz2 decompress failed: ", ret); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | bool IsFinished() override { return finished_; } |
| 144 |
nothing calls this directly
no test coverage detected