Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Adam Lesinski | a40e972 | 2015-11-24 19:11:46 -0800 | [diff] [blame] | 20 | #include "Diagnostics.h" |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 21 | #include "util/BigBuffer.h" |
| 22 | #include "util/Files.h" |
| 23 | #include "util/StringPiece.h" |
| 24 | |
| 25 | #include <fstream> |
| 26 | #include <memory> |
| 27 | #include <string> |
| 28 | #include <vector> |
| 29 | |
| 30 | namespace aapt { |
| 31 | |
| 32 | struct ArchiveEntry { |
| 33 | enum : uint32_t { |
| 34 | kCompress = 0x01, |
| 35 | kAlign = 0x02, |
| 36 | }; |
| 37 | |
| 38 | std::string path; |
| 39 | uint32_t flags; |
| 40 | size_t uncompressedSize; |
| 41 | }; |
| 42 | |
| 43 | struct IArchiveWriter { |
| 44 | virtual ~IArchiveWriter() = default; |
| 45 | |
Adam Lesinski | a40e972 | 2015-11-24 19:11:46 -0800 | [diff] [blame] | 46 | virtual bool startEntry(const StringPiece& path, uint32_t flags) = 0; |
| 47 | virtual bool writeEntry(const BigBuffer& buffer) = 0; |
| 48 | virtual bool writeEntry(const void* data, size_t len) = 0; |
| 49 | virtual bool finishEntry() = 0; |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 50 | }; |
| 51 | |
Adam Lesinski | a40e972 | 2015-11-24 19:11:46 -0800 | [diff] [blame] | 52 | std::unique_ptr<IArchiveWriter> createDirectoryArchiveWriter(IDiagnostics* diag, |
| 53 | const StringPiece& path); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 54 | |
Adam Lesinski | a40e972 | 2015-11-24 19:11:46 -0800 | [diff] [blame] | 55 | std::unique_ptr<IArchiveWriter> createZipFileArchiveWriter(IDiagnostics* diag, |
| 56 | const StringPiece& path); |
Adam Lesinski | 1ab598f | 2015-08-14 14:26:04 -0700 | [diff] [blame] | 57 | |
| 58 | } // namespace aapt |
| 59 | |
| 60 | #endif /* AAPT_FLATTEN_ARCHIVE_H */ |