| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include <bzlib.h> | 9 #include <bzlib.h> |
| 10 #include "update_engine/extent_writer.h" | 10 #include "update_engine/extent_writer.h" |
| 11 #include "update_engine/utils.h" | 11 #include "update_engine/utils.h" |
| 12 | 12 |
| 13 // BzipExtentWriter is a concrete ExtentWriter subclass that bzip-decompresses | 13 // BzipExtentWriter is a concrete ExtentWriter subclass that bzip-decompresses |
| 14 // what it's given in Write. It passes the decompressed data to an underlying | 14 // what it's given in Write. It passes the decompressed data to an underlying |
| 15 // ExtentWriter. | 15 // ExtentWriter. |
| 16 | 16 |
| 17 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
| 18 | 18 |
| 19 class BzipExtentWriter : public ExtentWriter { | 19 class BzipExtentWriter : public ExtentWriter { |
| 20 public: | 20 public: |
| 21 BzipExtentWriter(ExtentWriter* next) : next_(next) { | 21 BzipExtentWriter(ExtentWriter* next) : next_(next) { |
| 22 memset(&stream_, 0, sizeof(stream_)); | 22 memset(&stream_, 0, sizeof(stream_)); |
| 23 } | 23 } |
| 24 ~BzipExtentWriter() {} | 24 ~BzipExtentWriter() {} |
| 25 | 25 |
| 26 bool Init(int fd, const std::vector<Extent>& extents, uint32 block_size); | 26 bool Init(int fd, const std::vector<Extent>& extents, uint32_t block_size); |
| 27 bool Write(const void* bytes, size_t count); | 27 bool Write(const void* bytes, size_t count); |
| 28 bool EndImpl(); | 28 bool EndImpl(); |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 ExtentWriter* const next_; // The underlying ExtentWriter. | 31 ExtentWriter* const next_; // The underlying ExtentWriter. |
| 32 bz_stream stream_; // the libbz2 stream | 32 bz_stream stream_; // the libbz2 stream |
| 33 std::vector<char> input_buffer_; | 33 std::vector<char> input_buffer_; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 } // namespace chromeos_update_engine | 36 } // namespace chromeos_update_engine |
| 37 | 37 |
| 38 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ | 38 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_BZIP_EXTENT_WRITER_H__ |
| OLD | NEW |