1ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Protocol Buffers - Google's data interchange format
2ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Copyright 2008 Google Inc.  All rights reserved.
3ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// http://code.google.com/p/protobuf/
4ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
5ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Redistribution and use in source and binary forms, with or without
6ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// modification, are permitted provided that the following conditions are
7ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// met:
8ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
9ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Redistributions of source code must retain the above copyright
10ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// notice, this list of conditions and the following disclaimer.
11ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Redistributions in binary form must reproduce the above
12ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// copyright notice, this list of conditions and the following disclaimer
13ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// in the documentation and/or other materials provided with the
14ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// distribution.
15ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//     * Neither the name of Google Inc. nor the names of its
16ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// contributors may be used to endorse or promote products derived from
17ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// this software without specific prior written permission.
18ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville//
19ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
31ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville// Author: kenton@google.com (Kenton Varda)
32ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
33d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <vector>
34d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <google/protobuf/stubs/common.h>
35d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville#include <google/protobuf/io/zero_copy_stream.h>
36d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville
37d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace google {
38d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace protobuf {
39d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savillenamespace compiler {
40d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville
41d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Savilleclass ZipWriter {
42d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville public:
43d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  ZipWriter(io::ZeroCopyOutputStream* raw_output);
44d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  ~ZipWriter();
45d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville
46d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  bool Write(const string& filename, const string& contents);
47d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  bool WriteDirectory();
48ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
49d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville private:
50d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  struct FileInfo {
51d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville    string name;
52d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville    uint32 offset;
53d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville    uint32 size;
54d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville    uint32 crc32;
55d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  };
56ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
57d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  io::ZeroCopyOutputStream* raw_output_;
58d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville  vector<FileInfo> files_;
59d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville};
60ede38fe9b9f93888e6e41afc7abb09525f44da95Wink Saville
61d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville}  // namespace google
62d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville}  // namespace protobuf
63d0332953cda33fb4f8e24ebff9c49159b69c43d6Wink Saville}  // namespace compiler
64