blob: c4ddeb3163c01172726ba9e26c616c21e7721c4b [file] [log] [blame]
Adam Lesinski1ab598f2015-08-14 14:26:04 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef AAPT_FLATTEN_ARCHIVE_H
18#define AAPT_FLATTEN_ARCHIVE_H
19
20#include "util/BigBuffer.h"
21#include "util/Files.h"
22#include "util/StringPiece.h"
23
24#include <fstream>
25#include <memory>
26#include <string>
27#include <vector>
28
29namespace aapt {
30
31struct ArchiveEntry {
32 enum : uint32_t {
33 kCompress = 0x01,
34 kAlign = 0x02,
35 };
36
37 std::string path;
38 uint32_t flags;
39 size_t uncompressedSize;
40};
41
42struct IArchiveWriter {
43 virtual ~IArchiveWriter() = default;
44
45 virtual ArchiveEntry* writeEntry(const StringPiece& path, uint32_t flags,
46 const BigBuffer& buffer) = 0;
47 virtual ArchiveEntry* writeEntry(const StringPiece& path, uint32_t flags,
48 android::FileMap* fileMap, size_t offset, size_t len) = 0;
49};
50
51std::unique_ptr<IArchiveWriter> createDirectoryArchiveWriter(const StringPiece& path);
52
53std::unique_ptr<IArchiveWriter> createZipFileArchiveWriter(const StringPiece& path);
54
55} // namespace aapt
56
57#endif /* AAPT_FLATTEN_ARCHIVE_H */