1 // Protocol Buffers - Google's data interchange format 2 // Copyright 2008 Google Inc. All rights reserved. 3 // 4 // Use of this source code is governed by a BSD-style 5 // license that can be found in the LICENSE file or at 6 // https://developers.google.com/open-source/licenses/bsd 7 8 // Author: kenton@google.com (Kenton Varda) 9 #ifndef GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ 10 #define GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ 11 12 #include <cstdint> 13 #include <vector> 14 15 #include "google/protobuf/stubs/common.h" 16 #include "google/protobuf/io/zero_copy_stream.h" 17 18 namespace google { 19 namespace protobuf { 20 namespace compiler { 21 22 class ZipWriter { 23 public: 24 ZipWriter(io::ZeroCopyOutputStream* raw_output); 25 ~ZipWriter(); 26 27 bool Write(const std::string& filename, const std::string& contents); 28 bool WriteDirectory(); 29 30 private: 31 struct FileInfo { 32 std::string name; 33 uint32_t offset; 34 uint32_t size; 35 uint32_t crc32; 36 }; 37 38 io::ZeroCopyOutputStream* raw_output_; 39 std::vector<FileInfo> files_; 40 }; 41 42 } // namespace compiler 43 } // namespace protobuf 44 } // namespace google 45 46 #endif // GOOGLE_PROTOBUF_COMPILER_ZIP_WRITER_H__ 47