staticlib_unzip  1.0.6
 All Classes Namespaces Files Functions Variables
file_index.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2015, alex at staticlibs.net
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 /*
18  * File: file_index.hpp
19  * Author: alex
20  *
21  * Created on October 8, 2015, 6:58 PM
22  */
23 
24 #ifndef STATICLIB_UNZIP_FILE_INDEX_HPP
25 #define STATICLIB_UNZIP_FILE_INDEX_HPP
26 
27 #include <string>
28 #include <utility>
29 #include <vector>
30 #include <cstdint>
31 
32 #include "staticlib/pimpl.hpp"
33 
34 // do not includes zlib.h
35 #include "staticlib/compress/zip_compression_method.hpp"
36 
37 namespace staticlib {
38 namespace unzip {
39 
43 struct file_entry {
47  int32_t offset = -1;
51  int32_t comp_length = -1;
55  int32_t uncomp_length = -1;
59  uint16_t comp_method = 0;
60 
64  file_entry() { }
65 
74  file_entry(int32_t offset, int32_t comp_length, int32_t uncomp_length, uint16_t comp_method) :
75  offset(offset),
76  comp_length(comp_length),
77  uncomp_length(uncomp_length),
78  comp_method(comp_method) { }
79 
85  bool is_empty() {
86  return -1 == offset;
87  }
88 };
89 
93 class file_index : public sl::pimpl::object {
94 protected:
98  class impl;
99 public:
105  PIMPL_CONSTRUCTOR(file_index)
106 
107 
112  file_index(std::string zip_file_path);
113 
120  file_entry find_zip_entry(const std::string& name) const;
121 
127  const std::string& get_zip_file_path() const;
128 
134  const std::vector<std::string>& get_entries() const;
135 };
136 
137 } // namespace
138 }
139 
140 #endif /* STATICLIB_UNZIP_FILE_INDEX_HPP */
141