• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #pragma once
19 
20 #include <ziparchive/zip_archive.h>
21 
22 #include <vector>
23 
24 #include "android-base/off64_t.h"
25 
26 class ZipArchiveStreamEntry {
27  public:
~ZipArchiveStreamEntry()28   virtual ~ZipArchiveStreamEntry() {}
29 
30   virtual const std::vector<uint8_t>* Read() = 0;
31 
32   virtual bool Verify() = 0;
33 
34   static ZipArchiveStreamEntry* Create(ZipArchiveHandle handle, const ZipEntry& entry);
35   static ZipArchiveStreamEntry* CreateRaw(ZipArchiveHandle handle, const ZipEntry& entry);
36 
37  protected:
ZipArchiveStreamEntry(ZipArchiveHandle handle)38   ZipArchiveStreamEntry(ZipArchiveHandle handle) : handle_(handle) {}
39 
40   virtual bool Init(const ZipEntry& entry);
41 
42   ZipArchiveHandle handle_;
43 
44   off64_t offset_ = 0;
45   uint32_t crc32_ = 0u;
46 };
47