Tianjie Xu | 6528812 | 2017-10-13 15:10:58 -0700 | [diff] [blame] | 1 | // Copyright 2017 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef _BSDIFF_BZ2_DECOMPRESSOR_H_ |
| 6 | #define _BSDIFF_BZ2_DECOMPRESSOR_H_ |
| 7 | |
| 8 | #include <bzlib.h> |
| 9 | |
| 10 | #include "bsdiff/decompressor_interface.h" |
| 11 | |
| 12 | namespace bsdiff { |
| 13 | |
| 14 | class BZ2Decompressor : public DecompressorInterface { |
| 15 | public: |
| 16 | BZ2Decompressor() = default; |
Alex Deymo | 942194f | 2018-03-12 19:15:43 +0100 | [diff] [blame] | 17 | ~BZ2Decompressor(); |
Tianjie Xu | 6528812 | 2017-10-13 15:10:58 -0700 | [diff] [blame] | 18 | |
| 19 | bool SetInputData(const uint8_t* input_data, size_t size) override; |
| 20 | |
| 21 | bool Read(uint8_t* output_data, size_t bytes_to_output) override; |
| 22 | |
| 23 | bool Close() override; |
| 24 | |
| 25 | private: |
Alex Deymo | 942194f | 2018-03-12 19:15:43 +0100 | [diff] [blame] | 26 | // The low-level bzip2 stream. |
Tianjie Xu | 6528812 | 2017-10-13 15:10:58 -0700 | [diff] [blame] | 27 | bz_stream stream_; |
Alex Deymo | 942194f | 2018-03-12 19:15:43 +0100 | [diff] [blame] | 28 | |
| 29 | // Whether the stream_ is initialized. |
| 30 | bool stream_initialized_{false}; |
Tianjie Xu | 6528812 | 2017-10-13 15:10:58 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
| 33 | } // namespace bsdiff |
| 34 | |
Alex Deymo | 9bb4ddb | 2018-02-14 16:30:54 +0100 | [diff] [blame] | 35 | #endif |