Christopher Ferris | e6884ce | 2015-11-10 14:55:12 -0800 | [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 | // Read-only stream access to Zip archives entries. |
| 18 | #ifndef LIBZIPARCHIVE_ZIPARCHIVESTREAMENTRY_H_ |
| 19 | #define LIBZIPARCHIVE_ZIPARCHIVESTREAMENTRY_H_ |
| 20 | |
| 21 | #include <vector> |
| 22 | |
| 23 | #include <ziparchive/zip_archive.h> |
| 24 | |
| 25 | class ZipArchiveStreamEntry { |
| 26 | public: |
| 27 | virtual ~ZipArchiveStreamEntry() {} |
| 28 | |
| 29 | virtual const std::vector<uint8_t>* Read() = 0; |
| 30 | |
| 31 | virtual bool Verify() = 0; |
| 32 | |
| 33 | static ZipArchiveStreamEntry* Create(ZipArchiveHandle handle, const ZipEntry& entry); |
| 34 | static ZipArchiveStreamEntry* CreateRaw(ZipArchiveHandle handle, const ZipEntry& entry); |
| 35 | |
| 36 | protected: |
| 37 | ZipArchiveStreamEntry(ZipArchiveHandle handle) : handle_(handle) {} |
| 38 | |
| 39 | virtual bool Init(const ZipEntry& entry); |
| 40 | |
| 41 | ZipArchiveHandle handle_; |
| 42 | |
| 43 | uint32_t crc32_; |
| 44 | }; |
| 45 | |
| 46 | #endif // LIBZIPARCHIVE_ZIPARCHIVESTREAMENTRY_H_ |