4 * Redistribution and use in source and binary forms, with or without modification,
5 * are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright notice, this
11 * list of conditions and the following disclaimer in the documentation and/or
12 * other materials provided with the distribution.
14 * Neither the name of the NXP Semiconductor nor the names of its
15 * contributors may be used to endorse or promote products derived from this
16 * software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
41 /* Allow opportunistic use of the C++17 fall-through attribute . */
42 #if defined(__cplusplus) && __cplusplus >= 201703L
43 #define FALLTHROUGH [[fallthrough]]
55 uint32_t compressed_size
;
56 uint32_t uncompressed_size
;
62 uint16_t version_mini_extract
;
64 uint16_t compress_method
;
65 uint16_t last_modify_time
;
66 uint16_t last_modify_date
;
68 uint32_t compressed_size
;
69 uint32_t uncompressed_size
;
70 uint16_t file_name_length
;
71 uint16_t extrafield_length
;
74 struct Zip_central_dir
78 uint16_t version_mini_extract
;
80 uint16_t compress_method
;
81 uint16_t last_modify_time
;
82 uint16_t last_modify_date
;
84 uint32_t compressed_size
;
85 uint32_t uncompressed_size
;
86 uint16_t file_name_length
;
87 uint16_t extrafield_length
;
88 uint16_t file_comment_length
;
90 uint16_t internal_file_attr
;
91 uint32_t external_file_attr
;
96 struct Zip64_central_dir
100 uint16_t version_mini_extract
;
102 uint16_t compress_method
;
103 uint16_t last_modify_time
;
104 uint16_t last_modify_date
;
106 uint32_t compressed_size
;
107 uint32_t uncompressed_size
;
108 uint16_t file_name_length
;
109 uint16_t extrafield_length
;
110 uint16_t file_comment_length
;
111 uint16_t disk_number
;
112 uint16_t internal_file_attr
;
113 uint32_t external_file_attr
;
120 uint16_t num_of_thisdisk
;
121 uint16_t start_disk_of_dir
;
122 uint16_t num_of_dir_ondisk
;
124 uint32_t size_of_central_dir
;
125 uint32_t offset_of_central_dir
;
126 uint16_t length_of_comment
;
130 struct Zip64_eocd_locator
133 uint32_t num_of_thisdisk
;
134 uint64_t offset_of_eocd
;
135 uint32_t total_num_disks
;
141 uint64_t size_of_eocd
;
143 uint16_t version_mini_extract
;
144 uint32_t num_of_dir_ondisk
;
145 uint32_t num_of_disk
;
146 uint64_t total_ondisk
;
158 #define EOCD_SIGNATURE 0x06054b50
159 #define DIR_SIGNATURE 0x02014b50
160 #define DATA_SIGNATURE 0x08074b50
161 #define FILE_SIGNATURE 0x04034b50
162 #define EOCD64_LOCATOR_SIGNATURE 0x07064b50
163 #define EOCD64_SIGNATURE 0x06064b50
173 int decompress(Zip
*pZip
, std::shared_ptr
<FileBuffer
> p
);
176 std::string m_filename
;
177 uint32_t m_timestamp
;
179 size_t m_compressedsize
;
186 class Zip
: public Backfile
190 bool check_file_exist(std::string filename
);
191 int get_file_buff(std::string filename
, std::shared_ptr
<FileBuffer
>p
);
192 int Open(std::string filename
);
194 std::map
<std::string
, Zip_file_Info
> m_filemap
;