| 1 | /* mz_zip_rw.c -- Zip reader/writer |
| 2 | part of the minizip-ng project |
| 3 | |
| 4 | Copyright (C) Nathan Moinvaziri |
| 5 | https://github.com/zlib-ng/minizip-ng |
| 6 | |
| 7 | This program is distributed under the terms of the same license as zlib. |
| 8 | See the accompanying LICENSE file for the full text of the license. |
| 9 | */ |
| 10 | |
| 11 | #include "mz.h"cxx . . $ `<file>/mz.h`/ |
| 12 | #include "mz_crypt.h"cxx . . $ `<file>/mz_crypt.h`/ |
| 13 | #include "mz_os.h"cxx . . $ `<file>/mz_os.h`/ |
| 14 | #include "mz_strm.h"cxx . . $ `<file>/mz_strm.h`/ |
| 15 | #include "mz_strm_buf.h"cxx . . $ `<file>/mz_strm_buf.h`/ |
| 16 | #include "mz_strm_mem.h"cxx . . $ `<file>/mz_strm_mem.h`/ |
| 17 | #include "mz_strm_os.h"cxx . . $ `<file>/mz_strm_os.h`/ |
| 18 | #include "mz_strm_split.h"cxx . . $ `<file>/mz_strm_split.h`/ |
| 19 | #include "mz_strm_wzaes.h"cxx . . $ `<file>/mz_strm_wzaes.h`/ |
| 20 | #include "mz_zip.h"cxx . . $ `<file>/mz_zip.h`/ |
| 21 | |
| 22 | #include "mz_zip_rw.h"cxx . . $ `<file>/mz_zip_rw.h`/ |
| 23 | |
| 24 | /***************************************************************************/ |
| 25 | |
| 26 | #define MZ_DEFAULT_PROGRESS_INTERVALcxx . . $ `mz_zip_rw.c:26:9`! (1000u) |
| 27 | |
| 28 | #define MZ_ZIP_CD_FILENAMEcxx . . $ `mz_zip_rw.c:28:9`! ("__cdcd__") |
| 29 | |
| 30 | /***************************************************************************/ |
| 31 | |
| 32 | typedef struct mz_zip_reader_scxx . . $ mz_zip_reader_s# { |
| 33 | void *zip_handlecxx . . $ mz_zip_reader_s#zip_handle.; |
| 34 | void *file_streamcxx . . $ mz_zip_reader_s#file_stream.; |
| 35 | void *buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.; |
| 36 | void *split_streamcxx . . $ mz_zip_reader_s#split_stream.; |
| 37 | void *mem_streamcxx . . $ mz_zip_reader_s#mem_stream.; |
| 38 | void *hashcxx . . $ mz_zip_reader_s#hash.; |
| 39 | uint16_tcxx . . $ uint16_t# hash_algorithmcxx . . $ mz_zip_reader_s#hash_algorithm.; |
| 40 | uint16_tcxx . . $ uint16_t# hash_digest_sizecxx . . $ mz_zip_reader_s#hash_digest_size.; |
| 41 | mz_zip_filecxx . . $ mz_zip_file# *file_infocxx . . $ mz_zip_reader_s#file_info.; |
| 42 | char *patterncxx . . $ mz_zip_reader_s#pattern.; |
| 43 | uint8_tcxx . . $ uint8_t# pattern_ignore_casecxx . . $ mz_zip_reader_s#pattern_ignore_case.; |
| 44 | const char *passwordcxx . . $ mz_zip_reader_s#password.; |
| 45 | void *overwrite_userdatacxx . . $ mz_zip_reader_s#overwrite_userdata.; |
| 46 | mz_zip_reader_overwrite_cbcxx . . $ mz_zip_reader_overwrite_cb# overwrite_cbcxx . . $ mz_zip_reader_s#overwrite_cb.; |
| 47 | void *password_userdatacxx . . $ mz_zip_reader_s#password_userdata.; |
| 48 | mz_zip_reader_password_cbcxx . . $ mz_zip_reader_password_cb# password_cbcxx . . $ mz_zip_reader_s#password_cb.; |
| 49 | void *progress_userdatacxx . . $ mz_zip_reader_s#progress_userdata.; |
| 50 | mz_zip_reader_progress_cbcxx . . $ mz_zip_reader_progress_cb# progress_cbcxx . . $ mz_zip_reader_s#progress_cb.; |
| 51 | uint32_tcxx . . $ uint32_t# progress_cb_interval_mscxx . . $ mz_zip_reader_s#progress_cb_interval_ms.; |
| 52 | void *entry_userdatacxx . . $ mz_zip_reader_s#entry_userdata.; |
| 53 | mz_zip_reader_entry_cbcxx . . $ mz_zip_reader_entry_cb# entry_cbcxx . . $ mz_zip_reader_s#entry_cb.; |
| 54 | uint8_tcxx . . $ uint8_t# rawcxx . . $ mz_zip_reader_s#raw.; |
| 55 | uint8_tcxx . . $ uint8_t# buffercxx . . $ mz_zip_reader_s#buffer.[UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!]; |
| 56 | int32_tcxx . . $ int32_t# encodingcxx . . $ mz_zip_reader_s#encoding.; |
| 57 | uint8_tcxx . . $ uint8_t# sign_requiredcxx . . $ mz_zip_reader_s#sign_required.; |
| 58 | uint8_tcxx . . $ uint8_t# cd_verifiedcxx . . $ mz_zip_reader_s#cd_verified.; |
| 59 | uint8_tcxx . . $ uint8_t# cd_zippedcxx . . $ mz_zip_reader_s#cd_zipped.; |
| 60 | uint8_tcxx . . $ uint8_t# entry_verifiedcxx . . $ mz_zip_reader_s#entry_verified.; |
| 61 | uint8_tcxx . . $ uint8_t# recovercxx . . $ mz_zip_reader_s#recover.; |
| 62 | } mz_zip_readercxx . . $ mz_zip_reader#; |
| 63 | |
| 64 | /***************************************************************************/ |
| 65 | |
| 66 | int32_tcxx . . $ int32_t# mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(void *handle) { |
| 67 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 68 | if (!reader) |
| 69 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 70 | if (!reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) |
| 71 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 72 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 73 | } |
| 74 | |
| 75 | int32_tcxx . . $ int32_t# mz_zip_reader_opencxx . . $ mz_zip_reader_open(361d5d7064a2a85d).(void *handle, void *stream) { |
| 76 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 77 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 78 | |
| 79 | reader->cd_verifiedcxx . . $ mz_zip_reader_s#cd_verified. = 0; |
| 80 | reader->cd_zippedcxx . . $ mz_zip_reader_s#cd_zipped. = 0; |
| 81 | |
| 82 | reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle. = mz_zip_createcxx . . $ mz_zip_create(50c7df7de5344ebb).(); |
| 83 | if (!reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) |
| 84 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 85 | |
| 86 | mz_zip_set_recovercxx . . $ mz_zip_set_recover(5276b51c10b71c09).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., reader->recovercxx . . $ mz_zip_reader_s#recover.); |
| 87 | |
| 88 | err = mz_zip_opencxx . . $ mz_zip_open(8bc41909eac9e5d8).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., stream, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 89 | |
| 90 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 91 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 92 | return err; |
| 93 | } |
| 94 | |
| 95 | mz_zip_reader_unzip_cdcxx . . $ mz_zip_reader_unzip_cd(dedf1e9b1c614a07).(reader); |
| 96 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 97 | } |
| 98 | |
| 99 | int32_tcxx . . $ int32_t# mz_zip_reader_open_filecxx . . $ mz_zip_reader_open_file(f53b6be6549e6d95).(void *handle, const char *path) { |
| 100 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 101 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 102 | |
| 103 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 104 | |
| 105 | reader->file_streamcxx . . $ mz_zip_reader_s#file_stream. = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 106 | if (!reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.) |
| 107 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 108 | |
| 109 | reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream. = mz_stream_buffered_createcxx . . $ mz_stream_buffered_create(50c7df7de5344ebb).(); |
| 110 | if (!reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.) { |
| 111 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.); |
| 112 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 113 | } |
| 114 | |
| 115 | reader->split_streamcxx . . $ mz_zip_reader_s#split_stream. = mz_stream_split_createcxx . . $ mz_stream_split_create(50c7df7de5344ebb).(); |
| 116 | if (!reader->split_streamcxx . . $ mz_zip_reader_s#split_stream.) { |
| 117 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.); |
| 118 | mz_stream_buffered_deletecxx . . $ mz_stream_buffered_delete(539e082cf00e1f43).(&reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.); |
| 119 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 120 | } |
| 121 | |
| 122 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream., reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.); |
| 123 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(reader->split_streamcxx . . $ mz_zip_reader_s#split_stream., reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.); |
| 124 | |
| 125 | err = mz_stream_opencxx . . $ mz_stream_open(7083a8984c0735e8).(reader->split_streamcxx . . $ mz_zip_reader_s#split_stream., path, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 126 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 127 | err = mz_zip_reader_opencxx . . $ mz_zip_reader_open(361d5d7064a2a85d).(handle, reader->split_streamcxx . . $ mz_zip_reader_s#split_stream.); |
| 128 | return err; |
| 129 | } |
| 130 | |
| 131 | int32_tcxx . . $ int32_t# mz_zip_reader_open_file_in_memorycxx . . $ mz_zip_reader_open_file_in_memory(f53b6be6549e6d95).(void *handle, const char *path) { |
| 132 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 133 | void *file_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 134 | int64_tcxx . . $ int64_t# file_size = 0; |
| 135 | int32_tcxx . . $ int32_t# err = 0; |
| 136 | |
| 137 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 138 | |
| 139 | file_stream = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 140 | if (!file_stream) |
| 141 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 142 | |
| 143 | err = mz_stream_os_opencxx . . $ mz_stream_os_open(7083a8984c0735e8).(file_stream, path, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 144 | |
| 145 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 146 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 147 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 148 | return err; |
| 149 | } |
| 150 | |
| 151 | mz_stream_os_seekcxx . . $ mz_stream_os_seek(8bc0ff128761c75d).(file_stream, 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 152 | file_size = mz_stream_os_tellcxx . . $ mz_stream_os_tell(72c1818a5177f981).(file_stream); |
| 153 | mz_stream_os_seekcxx . . $ mz_stream_os_seek(8bc0ff128761c75d).(file_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 154 | |
| 155 | reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 156 | |
| 157 | if ((file_size <= 0) || (file_size > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) || (!reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.)) { |
| 158 | /* Memory size is too large or too small */ |
| 159 | |
| 160 | mz_stream_os_closecxx . . $ mz_stream_os_close(dedf1e9b1c614a07).(file_stream); |
| 161 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 162 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 163 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 164 | } |
| 165 | |
| 166 | mz_stream_mem_set_grow_sizecxx . . $ mz_stream_mem_set_grow_size(d0320739773070f2).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., (int32_tcxx . . $ int32_t#)file_size); |
| 167 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 168 | |
| 169 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., file_stream, (int32_tcxx . . $ int32_t#)file_size); |
| 170 | |
| 171 | mz_stream_os_closecxx . . $ mz_stream_os_close(dedf1e9b1c614a07).(file_stream); |
| 172 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 173 | |
| 174 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 175 | err = mz_zip_reader_opencxx . . $ mz_zip_reader_open(361d5d7064a2a85d).(handle, reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.); |
| 176 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 177 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 178 | |
| 179 | return err; |
| 180 | } |
| 181 | |
| 182 | int32_tcxx . . $ int32_t# mz_zip_reader_open_buffercxx . . $ mz_zip_reader_open_buffer(cce41a794abd061b).(void *handle, uint8_tcxx . . $ uint8_t# *buf, int32_tcxx . . $ int32_t# len, uint8_tcxx . . $ uint8_t# copy) { |
| 183 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 184 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 185 | |
| 186 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(handle); |
| 187 | |
| 188 | reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 189 | if (!reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.) |
| 190 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 191 | |
| 192 | if (copy) { |
| 193 | mz_stream_mem_set_grow_sizecxx . . $ mz_stream_mem_set_grow_size(d0320739773070f2).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., len); |
| 194 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 195 | mz_stream_mem_writecxx . . $ mz_stream_mem_write(91e54fd90adbb21).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., buf, len); |
| 196 | mz_stream_mem_seekcxx . . $ mz_stream_mem_seek(8bc0ff128761c75d).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 197 | } else { |
| 198 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 199 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream., buf, len); |
| 200 | } |
| 201 | |
| 202 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 203 | err = mz_zip_reader_opencxx . . $ mz_zip_reader_open(361d5d7064a2a85d).(handle, reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.); |
| 204 | |
| 205 | return err; |
| 206 | } |
| 207 | |
| 208 | int32_tcxx . . $ int32_t# mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(void *handle) { |
| 209 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 210 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 211 | |
| 212 | if (reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) { |
| 213 | err = mz_zip_closecxx . . $ mz_zip_close(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 214 | mz_zip_deletecxx . . $ mz_zip_delete(539e082cf00e1f43).(&reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 215 | } |
| 216 | |
| 217 | if (reader->split_streamcxx . . $ mz_zip_reader_s#split_stream.) { |
| 218 | mz_stream_split_closecxx . . $ mz_stream_split_close(dedf1e9b1c614a07).(reader->split_streamcxx . . $ mz_zip_reader_s#split_stream.); |
| 219 | mz_stream_split_deletecxx . . $ mz_stream_split_delete(539e082cf00e1f43).(&reader->split_streamcxx . . $ mz_zip_reader_s#split_stream.); |
| 220 | } |
| 221 | |
| 222 | if (reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.) |
| 223 | mz_stream_buffered_deletecxx . . $ mz_stream_buffered_delete(539e082cf00e1f43).(&reader->buffered_streamcxx . . $ mz_zip_reader_s#buffered_stream.); |
| 224 | |
| 225 | if (reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.) |
| 226 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&reader->file_streamcxx . . $ mz_zip_reader_s#file_stream.); |
| 227 | |
| 228 | if (reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.) { |
| 229 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.); |
| 230 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&reader->mem_streamcxx . . $ mz_zip_reader_s#mem_stream.); |
| 231 | } |
| 232 | |
| 233 | if (reader->patterncxx . . $ mz_zip_reader_s#pattern.) { |
| 234 | freecxx . . $ free(5d22bdacc48458e8).(reader->patterncxx . . $ mz_zip_reader_s#pattern.); |
| 235 | reader->patterncxx . . $ mz_zip_reader_s#pattern. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 236 | } |
| 237 | |
| 238 | return err; |
| 239 | } |
| 240 | |
| 241 | /***************************************************************************/ |
| 242 | |
| 243 | int32_tcxx . . $ int32_t# mz_zip_reader_unzip_cdcxx . . $ mz_zip_reader_unzip_cd(dedf1e9b1c614a07).(void *handle) { |
| 244 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 245 | mz_zip_filecxx . . $ mz_zip_file# *cd_info = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 246 | void *cd_mem_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 247 | void *new_cd_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 248 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 249 | uint64_tcxx . . $ uint64_t# number_entry = 0; |
| 250 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 251 | |
| 252 | err = mz_zip_reader_goto_first_entrycxx . . $ mz_zip_reader_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 253 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 254 | return err; |
| 255 | err = mz_zip_reader_entry_get_infocxx . . $ mz_zip_reader_entry_get_info(4dd5ee9bdbc1d978).(handle, &cd_info); |
| 256 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 257 | return err; |
| 258 | |
| 259 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(cd_info->filenamecxx . . $ mz_zip_file_s#filename., MZ_ZIP_CD_FILENAMEcxx . . $ `mz_zip_rw.c:28:9`!) != 0) |
| 260 | return mz_zip_reader_goto_first_entrycxx . . $ mz_zip_reader_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 261 | |
| 262 | err = mz_zip_reader_entry_opencxx . . $ mz_zip_reader_entry_open(dedf1e9b1c614a07).(handle); |
| 263 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 264 | return err; |
| 265 | |
| 266 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 267 | if (!file_extra_stream) |
| 268 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 269 | |
| 270 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(file_extra_stream, (void *)cd_info->extrafieldcxx . . $ mz_zip_file_s#extrafield., cd_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 271 | |
| 272 | err = mz_zip_extrafield_findcxx . . $ mz_zip_extrafield_find(70fe6fe7767d52f0).(file_extra_stream, MZ_ZIP_EXTENSION_CDCDcxx . . $ `mz.h:94:9`!, INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 273 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 274 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(file_extra_stream, &number_entry); |
| 275 | |
| 276 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 277 | |
| 278 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 279 | return err; |
| 280 | |
| 281 | mz_zip_get_cd_mem_streamcxx . . $ mz_zip_get_cd_mem_stream(1843ed636859e0d0).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., &cd_mem_stream); |
| 282 | if (mz_stream_mem_is_opencxx . . $ mz_stream_mem_is_open(dedf1e9b1c614a07).(cd_mem_stream) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 283 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(cd_mem_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 284 | |
| 285 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(cd_mem_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 286 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 287 | err = mz_stream_copy_streamcxx . . $ mz_stream_copy_stream(956b84005340d103).(cd_mem_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, handle, mz_zip_reader_entry_readcxx . . $ mz_zip_reader_entry_read(8bc41909eac9e5d8)., |
| 288 | (int32_tcxx . . $ int32_t#)cd_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 289 | } |
| 290 | |
| 291 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 292 | reader->cd_zippedcxx . . $ mz_zip_reader_s#cd_zipped. = 1; |
| 293 | |
| 294 | mz_zip_set_cd_streamcxx . . $ mz_zip_set_cd_stream(ebe495d140c0cd6c).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., 0, cd_mem_stream); |
| 295 | mz_zip_set_number_entrycxx . . $ mz_zip_set_number_entry(c0a5f96701d3f89).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., number_entry); |
| 296 | |
| 297 | err = mz_zip_reader_goto_first_entrycxx . . $ mz_zip_reader_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 298 | } |
| 299 | |
| 300 | reader->cd_verifiedcxx . . $ mz_zip_reader_s#cd_verified. = reader->entry_verifiedcxx . . $ mz_zip_reader_s#entry_verified.; |
| 301 | |
| 302 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&new_cd_stream); |
| 303 | return err; |
| 304 | } |
| 305 | |
| 306 | /***************************************************************************/ |
| 307 | |
| 308 | static int32_tcxx . . $ int32_t# mz_zip_reader_locate_entry_cbcxx . . $ mz_zip_reader_locate_entry_cb(88d650aec28b4c54).(void *handle, void *userdata, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 309 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)userdata; |
| 310 | int32_tcxx . . $ int32_t# result = 0; |
| 311 | MZ_UNUSEDcxx . . $ `mz.h:147:9`!(handle); |
| 312 | result = mz_path_compare_wccxx . . $ mz_path_compare_wc(6dbe66b8d729cbab).(file_info->filenamecxx . . $ mz_zip_file_s#filename., reader->patterncxx . . $ mz_zip_reader_s#pattern., reader->pattern_ignore_casecxx . . $ mz_zip_reader_s#pattern_ignore_case.); |
| 313 | return result; |
| 314 | } |
| 315 | |
| 316 | int32_tcxx . . $ int32_t# mz_zip_reader_goto_first_entrycxx . . $ mz_zip_reader_goto_first_entry(dedf1e9b1c614a07).(void *handle) { |
| 317 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 318 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 319 | |
| 320 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 321 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 322 | |
| 323 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 324 | mz_zip_reader_entry_closecxx . . $ mz_zip_reader_entry_close(dedf1e9b1c614a07).(handle); |
| 325 | |
| 326 | if (!reader->patterncxx . . $ mz_zip_reader_s#pattern.) |
| 327 | err = mz_zip_goto_first_entrycxx . . $ mz_zip_goto_first_entry(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 328 | else |
| 329 | err = mz_zip_locate_first_entrycxx . . $ mz_zip_locate_first_entry(ecab7b9312e6e1a9).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., reader, mz_zip_reader_locate_entry_cbcxx . . $ mz_zip_reader_locate_entry_cb(88d650aec28b4c54).); |
| 330 | |
| 331 | reader->file_infocxx . . $ mz_zip_reader_s#file_info. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 332 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 333 | err = mz_zip_entry_get_infocxx . . $ mz_zip_entry_get_info(4dd5ee9bdbc1d978).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., &reader->file_infocxx . . $ mz_zip_reader_s#file_info.); |
| 334 | |
| 335 | return err; |
| 336 | } |
| 337 | |
| 338 | int32_tcxx . . $ int32_t# mz_zip_reader_goto_next_entrycxx . . $ mz_zip_reader_goto_next_entry(dedf1e9b1c614a07).(void *handle) { |
| 339 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 340 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 341 | |
| 342 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 343 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 344 | |
| 345 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 346 | mz_zip_reader_entry_closecxx . . $ mz_zip_reader_entry_close(dedf1e9b1c614a07).(handle); |
| 347 | |
| 348 | if (!reader->patterncxx . . $ mz_zip_reader_s#pattern.) |
| 349 | err = mz_zip_goto_next_entrycxx . . $ mz_zip_goto_next_entry(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 350 | else |
| 351 | err = mz_zip_locate_next_entrycxx . . $ mz_zip_locate_next_entry(ecab7b9312e6e1a9).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., reader, mz_zip_reader_locate_entry_cbcxx . . $ mz_zip_reader_locate_entry_cb(88d650aec28b4c54).); |
| 352 | |
| 353 | reader->file_infocxx . . $ mz_zip_reader_s#file_info. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 354 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 355 | err = mz_zip_entry_get_infocxx . . $ mz_zip_entry_get_info(4dd5ee9bdbc1d978).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., &reader->file_infocxx . . $ mz_zip_reader_s#file_info.); |
| 356 | |
| 357 | return err; |
| 358 | } |
| 359 | |
| 360 | int32_tcxx . . $ int32_t# mz_zip_reader_locate_entrycxx . . $ mz_zip_reader_locate_entry(e99e7bb7a9acb132).(void *handle, const char *filename, uint8_tcxx . . $ uint8_t# ignore_case) { |
| 361 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 362 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 363 | |
| 364 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 365 | mz_zip_reader_entry_closecxx . . $ mz_zip_reader_entry_close(dedf1e9b1c614a07).(handle); |
| 366 | |
| 367 | err = mz_zip_locate_entrycxx . . $ mz_zip_locate_entry(e99e7bb7a9acb132).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., filename, ignore_case); |
| 368 | |
| 369 | reader->file_infocxx . . $ mz_zip_reader_s#file_info. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 370 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 371 | err = mz_zip_entry_get_infocxx . . $ mz_zip_entry_get_info(4dd5ee9bdbc1d978).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., &reader->file_infocxx . . $ mz_zip_reader_s#file_info.); |
| 372 | |
| 373 | return err; |
| 374 | } |
| 375 | |
| 376 | /***************************************************************************/ |
| 377 | |
| 378 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_opencxx . . $ mz_zip_reader_entry_open(dedf1e9b1c614a07).(void *handle) { |
| 379 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 380 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 381 | const char *password = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 382 | char password_buf[120]; |
| 383 | |
| 384 | reader->entry_verifiedcxx . . $ mz_zip_reader_s#entry_verified. = 0; |
| 385 | |
| 386 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 387 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 388 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info.) |
| 389 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 390 | |
| 391 | /* If the entry isn't open for reading, open it */ |
| 392 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 393 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 394 | |
| 395 | password = reader->passwordcxx . . $ mz_zip_reader_s#password.; |
| 396 | |
| 397 | /* Check if we need a password and ask for it if we need to */ |
| 398 | if (!password && reader->password_cbcxx . . $ mz_zip_reader_s#password_cb. && (reader->file_infocxx . . $ mz_zip_reader_s#file_info.->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!)) { |
| 399 | reader->password_cbcxx . . $ mz_zip_reader_s#password_cb.(handle, reader->password_userdatacxx . . $ mz_zip_reader_s#password_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., password_buf, sizeof(password_buf)); |
| 400 | |
| 401 | password = password_buf; |
| 402 | } |
| 403 | |
| 404 | err = mz_zip_entry_read_opencxx . . $ mz_zip_entry_read_open(5e2f72b4b9a4e6c4).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., reader->rawcxx . . $ mz_zip_reader_s#raw., password); |
| 405 | #ifndef MZ_ZIP_NO_CRYPTO |
| 406 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 407 | return err; |
| 408 | |
| 409 | if (mz_zip_reader_entry_get_first_hashcxx . . $ mz_zip_reader_entry_get_first_hash(9a4a45287d8af1f7).(handle, &reader->hash_algorithmcxx . . $ mz_zip_reader_s#hash_algorithm., &reader->hash_digest_sizecxx . . $ mz_zip_reader_s#hash_digest_size.) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 410 | reader->hashcxx . . $ mz_zip_reader_s#hash. = mz_crypt_sha_createcxx . . $ mz_crypt_sha_create(50c7df7de5344ebb).(); |
| 411 | if (!reader->hashcxx . . $ mz_zip_reader_s#hash.) |
| 412 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 413 | |
| 414 | if (reader->hash_algorithmcxx . . $ mz_zip_reader_s#hash_algorithm. == MZ_HASH_SHA1cxx . . $ `mz.h:127:9`!) |
| 415 | err = mz_crypt_sha_set_algorithmcxx . . $ mz_crypt_sha_set_algorithm(f805ef7ae580f896).(reader->hashcxx . . $ mz_zip_reader_s#hash., MZ_HASH_SHA1cxx . . $ `mz.h:127:9`!); |
| 416 | else if (reader->hash_algorithmcxx . . $ mz_zip_reader_s#hash_algorithm. == MZ_HASH_SHA256cxx . . $ `mz.h:131:9`!) |
| 417 | err = mz_crypt_sha_set_algorithmcxx . . $ mz_crypt_sha_set_algorithm(f805ef7ae580f896).(reader->hashcxx . . $ mz_zip_reader_s#hash., MZ_HASH_SHA256cxx . . $ `mz.h:131:9`!); |
| 418 | else |
| 419 | err = MZ_SUPPORT_ERRORcxx . . $ `mz.h:38:9`!; |
| 420 | |
| 421 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 422 | mz_crypt_sha_begincxx . . $ mz_crypt_sha_begin(dedf1e9b1c614a07).(reader->hashcxx . . $ mz_zip_reader_s#hash.); |
| 423 | } else if (reader->sign_requiredcxx . . $ mz_zip_reader_s#sign_required. && !reader->cd_verifiedcxx . . $ mz_zip_reader_s#cd_verified.) |
| 424 | err = MZ_SIGN_ERRORcxx . . $ `mz.h:46:9`!; |
| 425 | #endif |
| 426 | |
| 427 | return err; |
| 428 | } |
| 429 | |
| 430 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_closecxx . . $ mz_zip_reader_entry_close(dedf1e9b1c614a07).(void *handle) { |
| 431 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 432 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 433 | int32_tcxx . . $ int32_t# err_close = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 434 | #ifndef MZ_ZIP_NO_CRYPTO |
| 435 | int32_tcxx . . $ int32_t# err_hash = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 436 | uint8_tcxx . . $ uint8_t# computed_hash[MZ_HASH_MAX_SIZEcxx . . $ `mz.h:137:9`!]; |
| 437 | uint8_tcxx . . $ uint8_t# expected_hash[MZ_HASH_MAX_SIZEcxx . . $ `mz.h:137:9`!]; |
| 438 | |
| 439 | if (reader->hashcxx . . $ mz_zip_reader_s#hash.) { |
| 440 | mz_crypt_sha_endcxx . . $ mz_crypt_sha_end(78b1a2a92e9cffd0).(reader->hashcxx . . $ mz_zip_reader_s#hash., computed_hash, sizeof(computed_hash)); |
| 441 | mz_crypt_sha_deletecxx . . $ mz_crypt_sha_delete(539e082cf00e1f43).(&reader->hashcxx . . $ mz_zip_reader_s#hash.); |
| 442 | |
| 443 | err_hash = |
| 444 | mz_zip_reader_entry_get_hashcxx . . $ mz_zip_reader_entry_get_hash(14e4b9d7e3b43e16).(handle, reader->hash_algorithmcxx . . $ mz_zip_reader_s#hash_algorithm., expected_hash, reader->hash_digest_sizecxx . . $ mz_zip_reader_s#hash_digest_size.); |
| 445 | |
| 446 | if (err_hash == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 447 | /* Verify expected hash against computed hash */ |
| 448 | if (memcmpcxx . . $ memcmp(36f949851efa3055).(computed_hash, expected_hash, reader->hash_digest_sizecxx . . $ mz_zip_reader_s#hash_digest_size.) != 0) |
| 449 | err = MZ_CRC_ERRORcxx . . $ `mz.h:34:9`!; |
| 450 | } |
| 451 | } |
| 452 | #endif |
| 453 | |
| 454 | err_close = mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 455 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 456 | err = err_close; |
| 457 | return err; |
| 458 | } |
| 459 | |
| 460 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_readcxx . . $ mz_zip_reader_entry_read(8bc41909eac9e5d8).(void *handle, void *buf, int32_tcxx . . $ int32_t# len) { |
| 461 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 462 | int32_tcxx . . $ int32_t# read = 0; |
| 463 | read = mz_zip_entry_readcxx . . $ mz_zip_entry_read(8bc41909eac9e5d8).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., buf, len); |
| 464 | #ifndef MZ_ZIP_NO_CRYPTO |
| 465 | if (read > 0 && reader->hashcxx . . $ mz_zip_reader_s#hash.) |
| 466 | mz_crypt_sha_updatecxx . . $ mz_crypt_sha_update(91e54fd90adbb21).(reader->hashcxx . . $ mz_zip_reader_s#hash., buf, read); |
| 467 | #endif |
| 468 | return read; |
| 469 | } |
| 470 | |
| 471 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_get_hashcxx . . $ mz_zip_reader_entry_get_hash(14e4b9d7e3b43e16).(void *handle, uint16_tcxx . . $ uint16_t# algorithm, uint8_tcxx . . $ uint8_t# *digest, int32_tcxx . . $ int32_t# digest_size) { |
| 472 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 473 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 474 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 475 | int32_tcxx . . $ int32_t# return_err = MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 476 | uint16_tcxx . . $ uint16_t# cur_algorithm = 0; |
| 477 | uint16_tcxx . . $ uint16_t# cur_digest_size = 0; |
| 478 | |
| 479 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 480 | if (!file_extra_stream) |
| 481 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 482 | |
| 483 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(file_extra_stream, (void *)reader->file_infocxx . . $ mz_zip_reader_s#file_info.->extrafieldcxx . . $ mz_zip_file_s#extrafield., |
| 484 | reader->file_infocxx . . $ mz_zip_reader_s#file_info.->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 485 | |
| 486 | do { |
| 487 | err = mz_zip_extrafield_findcxx . . $ mz_zip_extrafield_find(70fe6fe7767d52f0).(file_extra_stream, MZ_ZIP_EXTENSION_HASHcxx . . $ `mz.h:93:9`!, INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 488 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 489 | break; |
| 490 | |
| 491 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &cur_algorithm); |
| 492 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 493 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &cur_digest_size); |
| 494 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (cur_algorithm == algorithm) && (cur_digest_size <= digest_size) && |
| 495 | (cur_digest_size <= MZ_HASH_MAX_SIZEcxx . . $ `mz.h:137:9`!)) { |
| 496 | /* Read hash digest */ |
| 497 | if (mz_stream_readcxx . . $ mz_stream_read(8bc41909eac9e5d8).(file_extra_stream, digest, digest_size) == cur_digest_size) |
| 498 | return_err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 499 | break; |
| 500 | } else { |
| 501 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, cur_digest_size, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 502 | } |
| 503 | } while (err == MZ_OKcxx . . $ `mz.h:21:9`!); |
| 504 | |
| 505 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 506 | |
| 507 | return return_err; |
| 508 | } |
| 509 | |
| 510 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_get_first_hashcxx . . $ mz_zip_reader_entry_get_first_hash(9a4a45287d8af1f7).(void *handle, uint16_tcxx . . $ uint16_t# *algorithm, uint16_tcxx . . $ uint16_t# *digest_size) { |
| 511 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 512 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 513 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 514 | uint16_tcxx . . $ uint16_t# cur_algorithm = 0; |
| 515 | uint16_tcxx . . $ uint16_t# cur_digest_size = 0; |
| 516 | |
| 517 | if (!reader || !algorithm) |
| 518 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 519 | |
| 520 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 521 | if (!file_extra_stream) |
| 522 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 523 | |
| 524 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(file_extra_stream, (void *)reader->file_infocxx . . $ mz_zip_reader_s#file_info.->extrafieldcxx . . $ mz_zip_file_s#extrafield., |
| 525 | reader->file_infocxx . . $ mz_zip_reader_s#file_info.->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 526 | |
| 527 | err = mz_zip_extrafield_findcxx . . $ mz_zip_extrafield_find(70fe6fe7767d52f0).(file_extra_stream, MZ_ZIP_EXTENSION_HASHcxx . . $ `mz.h:93:9`!, INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 528 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 529 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &cur_algorithm); |
| 530 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 531 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &cur_digest_size); |
| 532 | |
| 533 | if (algorithm) |
| 534 | *algorithm = cur_algorithm; |
| 535 | if (digest_size) |
| 536 | *digest_size = cur_digest_size; |
| 537 | |
| 538 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 539 | |
| 540 | return err; |
| 541 | } |
| 542 | |
| 543 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_get_infocxx . . $ mz_zip_reader_entry_get_info(4dd5ee9bdbc1d978).(void *handle, mz_zip_filecxx . . $ mz_zip_file# **file_info) { |
| 544 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 545 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 546 | if (!file_info || mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 547 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 548 | *file_info = reader->file_infocxx . . $ mz_zip_reader_s#file_info.; |
| 549 | if (!*file_info) |
| 550 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 551 | return err; |
| 552 | } |
| 553 | |
| 554 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_is_dircxx . . $ mz_zip_reader_entry_is_dir(dedf1e9b1c614a07).(void *handle) { |
| 555 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 556 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 557 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 558 | return mz_zip_entry_is_dircxx . . $ mz_zip_entry_is_dir(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.); |
| 559 | } |
| 560 | |
| 561 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_save_processcxx . . $ mz_zip_reader_entry_save_process(9cf5ea4574f2bbfb).(void *handle, void *stream, mz_stream_write_cbcxx . . $ mz_stream_write_cb# write_cb) { |
| 562 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 563 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 564 | int32_tcxx . . $ int32_t# read = 0; |
| 565 | int32_tcxx . . $ int32_t# written = 0; |
| 566 | |
| 567 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 568 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 569 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info. || !write_cb) |
| 570 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 571 | |
| 572 | /* If the entry isn't open for reading, open it */ |
| 573 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 574 | err = mz_zip_reader_entry_opencxx . . $ mz_zip_reader_entry_open(dedf1e9b1c614a07).(handle); |
| 575 | |
| 576 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 577 | return err; |
| 578 | |
| 579 | /* Unzip entry in zip file */ |
| 580 | read = mz_zip_reader_entry_readcxx . . $ mz_zip_reader_entry_read(8bc41909eac9e5d8).(handle, reader->buffercxx . . $ mz_zip_reader_s#buffer., sizeof(reader->buffercxx . . $ mz_zip_reader_s#buffer.)); |
| 581 | |
| 582 | if (read == 0) { |
| 583 | /* If we are done close the entry */ |
| 584 | err = mz_zip_reader_entry_closecxx . . $ mz_zip_reader_entry_close(dedf1e9b1c614a07).(handle); |
| 585 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 586 | return err; |
| 587 | |
| 588 | return MZ_END_OF_STREAMcxx . . $ `mz.h:29:9`!; |
| 589 | } |
| 590 | |
| 591 | if (read > 0) { |
| 592 | /* Write the data to the specified stream */ |
| 593 | written = write_cb(stream, reader->buffercxx . . $ mz_zip_reader_s#buffer., read); |
| 594 | if (written != read) |
| 595 | return MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 596 | } |
| 597 | |
| 598 | return read; |
| 599 | } |
| 600 | |
| 601 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_savecxx . . $ mz_zip_reader_entry_save(9cf5ea4574f2bbfb).(void *handle, void *stream, mz_stream_write_cbcxx . . $ mz_stream_write_cb# write_cb) { |
| 602 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 603 | uint64_tcxx . . $ uint64_t# current_time = 0; |
| 604 | uint64_tcxx . . $ uint64_t# update_time = 0; |
| 605 | int64_tcxx . . $ int64_t# current_pos = 0; |
| 606 | int64_tcxx . . $ int64_t# update_pos = 0; |
| 607 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 608 | int32_tcxx . . $ int32_t# written = 0; |
| 609 | |
| 610 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 611 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 612 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info.) |
| 613 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 614 | |
| 615 | /* Update the progress at the beginning */ |
| 616 | if (reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb.) |
| 617 | reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb.(handle, reader->progress_userdatacxx . . $ mz_zip_reader_s#progress_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., current_pos); |
| 618 | |
| 619 | /* Write data to stream until done */ |
| 620 | while (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 621 | written = mz_zip_reader_entry_save_processcxx . . $ mz_zip_reader_entry_save_process(9cf5ea4574f2bbfb).(handle, stream, write_cb); |
| 622 | if (written == MZ_END_OF_STREAMcxx . . $ `mz.h:29:9`!) |
| 623 | break; |
| 624 | if (written > 0) |
| 625 | current_pos += written; |
| 626 | if (written < 0) |
| 627 | err = written; |
| 628 | |
| 629 | /* Update progress if enough time have passed */ |
| 630 | current_time = mz_os_ms_timecxx . . $ mz_os_ms_time(f708dce9a8856c70).(); |
| 631 | if ((current_time - update_time) > reader->progress_cb_interval_mscxx . . $ mz_zip_reader_s#progress_cb_interval_ms.) { |
| 632 | if (reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb.) |
| 633 | reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb.(handle, reader->progress_userdatacxx . . $ mz_zip_reader_s#progress_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., current_pos); |
| 634 | |
| 635 | update_pos = current_pos; |
| 636 | update_time = current_time; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | /* Update the progress at the end */ |
| 641 | if (reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb. && update_pos != current_pos) |
| 642 | reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb.(handle, reader->progress_userdatacxx . . $ mz_zip_reader_s#progress_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., current_pos); |
| 643 | |
| 644 | return err; |
| 645 | } |
| 646 | |
| 647 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_save_filecxx . . $ mz_zip_reader_entry_save_file(f53b6be6549e6d95).(void *handle, const char *path) { |
| 648 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 649 | void *stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 650 | uint32_tcxx . . $ uint32_t# target_attrib = 0; |
| 651 | int32_tcxx . . $ int32_t# err_attrib = 0; |
| 652 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 653 | int32_tcxx . . $ int32_t# err_cb = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 654 | char *pathwfs = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 655 | char *directory = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 656 | |
| 657 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 658 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 659 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info. || !path) |
| 660 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 661 | |
| 662 | pathwfs = (char *)strdupcxx . . $ strdup(a8b8e32347182212).(path); |
| 663 | if (!pathwfs) |
| 664 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 665 | |
| 666 | if (reader->entry_cbcxx . . $ mz_zip_reader_s#entry_cb.) |
| 667 | reader->entry_cbcxx . . $ mz_zip_reader_s#entry_cb.(handle, reader->entry_userdatacxx . . $ mz_zip_reader_s#entry_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., pathwfs); |
| 668 | |
| 669 | directory = (char *)strdupcxx . . $ strdup(a8b8e32347182212).(pathwfs); |
| 670 | if (!directory) { |
| 671 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 672 | goto save_cleanup; |
| 673 | } |
| 674 | mz_path_remove_filenamecxx . . $ mz_path_remove_filename(1ef8e6ec083aabb9).(directory); |
| 675 | |
| 676 | /* If it is a directory entry then create a directory instead of writing file */ |
| 677 | if ((mz_zip_entry_is_dircxx . . $ mz_zip_entry_is_dir(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) && (mz_zip_entry_is_symlinkcxx . . $ mz_zip_entry_is_symlink(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) != MZ_OKcxx . . $ `mz.h:21:9`!)) { |
| 678 | err = mz_dir_makecxx . . $ mz_dir_make(5c4306d8553b3696).(directory); |
| 679 | goto save_cleanup; |
| 680 | } |
| 681 | |
| 682 | /* Check if file exists and ask if we want to overwrite */ |
| 683 | if (reader->overwrite_cbcxx . . $ mz_zip_reader_s#overwrite_cb. && mz_os_file_existscxx . . $ mz_os_file_exists(5c4306d8553b3696).(pathwfs) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 684 | err_cb = reader->overwrite_cbcxx . . $ mz_zip_reader_s#overwrite_cb.(handle, reader->overwrite_userdatacxx . . $ mz_zip_reader_s#overwrite_userdata., reader->file_infocxx . . $ mz_zip_reader_s#file_info., pathwfs); |
| 685 | if (err_cb != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 686 | goto save_cleanup; |
| 687 | /* We want to overwrite the file so we delete the existing one */ |
| 688 | mz_os_unlinkcxx . . $ mz_os_unlink(5c4306d8553b3696).(pathwfs); |
| 689 | } |
| 690 | |
| 691 | /* If symbolic link then properly construct destination path and link path */ |
| 692 | if ((mz_zip_entry_is_symlinkcxx . . $ mz_zip_entry_is_symlink(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) && (mz_path_has_slashcxx . . $ mz_path_has_slash(5c4306d8553b3696).(pathwfs) == MZ_OKcxx . . $ `mz.h:21:9`!)) { |
| 693 | mz_path_remove_slashcxx . . $ mz_path_remove_slash(1ef8e6ec083aabb9).(pathwfs); |
| 694 | mz_path_remove_filenamecxx . . $ mz_path_remove_filename(1ef8e6ec083aabb9).(directory); |
| 695 | } |
| 696 | |
| 697 | /* Create the output directory if it doesn't already exist */ |
| 698 | if (mz_os_is_dircxx . . $ mz_os_is_dir(5c4306d8553b3696).(directory) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 699 | err = mz_dir_makecxx . . $ mz_dir_make(5c4306d8553b3696).(directory); |
| 700 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 701 | goto save_cleanup; |
| 702 | } |
| 703 | |
| 704 | /* If it is a symbolic link then create symbolic link instead of writing file */ |
| 705 | if (mz_zip_entry_is_symlinkcxx . . $ mz_zip_entry_is_symlink(dedf1e9b1c614a07).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 706 | if (reader->file_infocxx . . $ mz_zip_reader_s#file_info.->linknamecxx . . $ mz_zip_file_s#linkname. && *reader->file_infocxx . . $ mz_zip_reader_s#file_info.->linknamecxx . . $ mz_zip_file_s#linkname. != 0) { |
| 707 | /* Create symbolic link from UNIX1 extrafield */ |
| 708 | err = mz_os_make_symlinkcxx . . $ mz_os_make_symlink(5ae29d726ae57f88).(pathwfs, reader->file_infocxx . . $ mz_zip_reader_s#file_info.->linknamecxx . . $ mz_zip_file_s#linkname.); |
| 709 | } else if (reader->file_infocxx . . $ mz_zip_reader_s#file_info.->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. < UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) { |
| 710 | /* Create symbolic link from zip entry contents */ |
| 711 | stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 712 | if (!stream) { |
| 713 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 714 | goto save_cleanup; |
| 715 | } |
| 716 | |
| 717 | err = mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 718 | |
| 719 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 720 | err = mz_zip_reader_entry_savecxx . . $ mz_zip_reader_entry_save(9cf5ea4574f2bbfb).(handle, stream, mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).); |
| 721 | |
| 722 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 723 | err = mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(stream, 0); |
| 724 | |
| 725 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 726 | const char *linkname = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 727 | if (mz_stream_mem_get_buffercxx . . $ mz_stream_mem_get_buffer(d7fce53f66dcd9ef).(stream, (const void **)&linkname) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 728 | err = mz_os_make_symlinkcxx . . $ mz_os_make_symlink(5ae29d726ae57f88).(pathwfs, linkname); |
| 729 | } |
| 730 | |
| 731 | mz_stream_mem_closecxx . . $ mz_stream_mem_close(dedf1e9b1c614a07).(stream); |
| 732 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&stream); |
| 733 | } |
| 734 | |
| 735 | /* Don't check return value because we aren't validating symbolic link target */ |
| 736 | goto save_cleanup; |
| 737 | } |
| 738 | |
| 739 | /* Create the file on disk so we can save to it */ |
| 740 | stream = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 741 | if (!stream) { |
| 742 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 743 | goto save_cleanup; |
| 744 | } |
| 745 | |
| 746 | err = mz_stream_os_opencxx . . $ mz_stream_os_open(7083a8984c0735e8).(stream, pathwfs, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 747 | |
| 748 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 749 | err = mz_zip_reader_entry_savecxx . . $ mz_zip_reader_entry_save(9cf5ea4574f2bbfb).(handle, stream, mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).); |
| 750 | |
| 751 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(stream); |
| 752 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&stream); |
| 753 | |
| 754 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 755 | /* Set the time of the file that has been created */ |
| 756 | mz_os_set_file_datecxx . . $ mz_os_set_file_date(3744568063355712).(pathwfs, reader->file_infocxx . . $ mz_zip_reader_s#file_info.->modified_datecxx . . $ mz_zip_file_s#modified_date., reader->file_infocxx . . $ mz_zip_reader_s#file_info.->accessed_datecxx . . $ mz_zip_file_s#accessed_date., |
| 757 | reader->file_infocxx . . $ mz_zip_reader_s#file_info.->creation_datecxx . . $ mz_zip_file_s#creation_date.); |
| 758 | } |
| 759 | |
| 760 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 761 | /* Set file attributes for the correct system */ |
| 762 | err_attrib = |
| 763 | mz_zip_attrib_convertcxx . . $ mz_zip_attrib_convert(20c6f379b34f0b73).(MZ_HOST_SYSTEMcxx . . $ `mz.h:102:9`!(reader->file_info->version_madeby), reader->file_infocxx . . $ mz_zip_reader_s#file_info.->external_facxx . . $ mz_zip_file_s#external_fa., |
| 764 | MZ_VERSION_MADEBY_HOST_SYSTEMcxx . . $ `mz_os.h:27:11`!, &target_attrib); |
| 765 | |
| 766 | if (err_attrib == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 767 | mz_os_set_file_attribscxx . . $ mz_os_set_file_attribs(1df18506ef0a631b).(pathwfs, target_attrib); |
| 768 | } |
| 769 | |
| 770 | save_cleanup: |
| 771 | freecxx . . $ free(5d22bdacc48458e8).(pathwfs); |
| 772 | freecxx . . $ free(5d22bdacc48458e8).(directory); |
| 773 | |
| 774 | return err; |
| 775 | } |
| 776 | |
| 777 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_save_buffercxx . . $ mz_zip_reader_entry_save_buffer(8bc41909eac9e5d8).(void *handle, void *buf, int32_tcxx . . $ int32_t# len) { |
| 778 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 779 | void *mem_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 780 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 781 | |
| 782 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 783 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 784 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info. || reader->file_infocxx . . $ mz_zip_reader_s#file_info.->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. > INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!) |
| 785 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 786 | if (len != (int32_tcxx . . $ int32_t#)reader->file_infocxx . . $ mz_zip_reader_s#file_info.->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.) |
| 787 | return MZ_BUF_ERRORcxx . . $ `mz.h:25:9`!; |
| 788 | |
| 789 | /* Create a memory stream backed by our buffer and save to it */ |
| 790 | mem_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 791 | if (!mem_stream) |
| 792 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 793 | |
| 794 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(mem_stream, buf, len); |
| 795 | |
| 796 | err = mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(mem_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 797 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 798 | err = mz_zip_reader_entry_savecxx . . $ mz_zip_reader_entry_save(9cf5ea4574f2bbfb).(handle, mem_stream, mz_stream_mem_writecxx . . $ mz_stream_mem_write(91e54fd90adbb21).); |
| 799 | |
| 800 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&mem_stream); |
| 801 | return err; |
| 802 | } |
| 803 | |
| 804 | int32_tcxx . . $ int32_t# mz_zip_reader_entry_save_buffer_lengthcxx . . $ mz_zip_reader_entry_save_buffer_length(dedf1e9b1c614a07).(void *handle) { |
| 805 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 806 | |
| 807 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 808 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 809 | if (!reader->file_infocxx . . $ mz_zip_reader_s#file_info. || reader->file_infocxx . . $ mz_zip_reader_s#file_info.->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. > INT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:112:10`!) |
| 810 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 811 | |
| 812 | /* Get the maximum size required for the save buffer */ |
| 813 | return (int32_tcxx . . $ int32_t#)reader->file_infocxx . . $ mz_zip_reader_s#file_info.->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.; |
| 814 | } |
| 815 | |
| 816 | /***************************************************************************/ |
| 817 | |
| 818 | int32_tcxx . . $ int32_t# mz_zip_reader_save_allcxx . . $ mz_zip_reader_save_all(f53b6be6549e6d95).(void *handle, const char *destination_dir) { |
| 819 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 820 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 821 | int32_tcxx . . $ int32_t# utf8_name_size = 0; |
| 822 | int32_tcxx . . $ int32_t# resolved_name_size = 0; |
| 823 | int32_tcxx . . $ int32_t# destination_dir_len = 0; |
| 824 | char *utf8_string = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 825 | char *path = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 826 | char *utf8_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 827 | char *resolved_name = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 828 | char *new_alloc = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 829 | |
| 830 | err = mz_zip_reader_goto_first_entrycxx . . $ mz_zip_reader_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 831 | |
| 832 | if (err == MZ_END_OF_LISTcxx . . $ `mz.h:28:9`!) |
| 833 | return err; |
| 834 | |
| 835 | if (destination_dir) |
| 836 | destination_dir_len = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(destination_dir) + 1; |
| 837 | |
| 838 | while (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 839 | /* Assume 4 bytes per character needed + 1 for terminating null */ |
| 840 | utf8_name_size = reader->file_infocxx . . $ mz_zip_reader_s#file_info.->filename_sizecxx . . $ mz_zip_file_s#filename_size. * 4 + 1; |
| 841 | resolved_name_size = utf8_name_size; |
| 842 | |
| 843 | if (destination_dir) { |
| 844 | /* +1 is for the "/" separator */ |
| 845 | resolved_name_size += destination_dir_len; |
| 846 | } |
| 847 | |
| 848 | new_alloc = (char *)realloccxx . . $ realloc(417ab160f6baadc6).(path, resolved_name_size); |
| 849 | if (!new_alloc) { |
| 850 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 851 | goto save_all_cleanup; |
| 852 | } |
| 853 | path = new_alloc; |
| 854 | new_alloc = (char *)realloccxx . . $ realloc(417ab160f6baadc6).(utf8_name, utf8_name_size); |
| 855 | if (!new_alloc) { |
| 856 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 857 | goto save_all_cleanup; |
| 858 | } |
| 859 | utf8_name = new_alloc; |
| 860 | new_alloc = (char *)realloccxx . . $ realloc(417ab160f6baadc6).(resolved_name, resolved_name_size); |
| 861 | if (!new_alloc) { |
| 862 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 863 | goto save_all_cleanup; |
| 864 | } |
| 865 | resolved_name = new_alloc; |
| 866 | |
| 867 | /* Construct output path */ |
| 868 | path[0] = 0; |
| 869 | |
| 870 | strncpycxx . . $ strncpy(255158a415b673b0).(utf8_name, reader->file_infocxx . . $ mz_zip_reader_s#file_info.->filenamecxx . . $ mz_zip_file_s#filename., utf8_name_size - 1); |
| 871 | utf8_name[utf8_name_size - 1] = 0; |
| 872 | |
| 873 | if ((reader->encodingcxx . . $ mz_zip_reader_s#encoding. > 0) && (reader->file_infocxx . . $ mz_zip_reader_s#file_info.->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_UTF8cxx . . $ `mz.h:84:9`!) == 0) { |
| 874 | utf8_string = mz_os_utf8_string_createcxx . . $ mz_os_utf8_string_create(2050848944e00d54).(reader->file_infocxx . . $ mz_zip_reader_s#file_info.->filenamecxx . . $ mz_zip_file_s#filename., reader->encodingcxx . . $ mz_zip_reader_s#encoding.); |
| 875 | if (utf8_string) { |
| 876 | strncpycxx . . $ strncpy(255158a415b673b0).(utf8_name, utf8_string, utf8_name_size - 1); |
| 877 | utf8_name[utf8_name_size - 1] = 0; |
| 878 | mz_os_utf8_string_deletecxx . . $ mz_os_utf8_string_delete(3ed91490e421178f).(&utf8_string); |
| 879 | } |
| 880 | } |
| 881 | |
| 882 | err = mz_path_resolvecxx . . $ mz_path_resolve(89c8e27db0bdb94e).(utf8_name, resolved_name, resolved_name_size); |
| 883 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 884 | break; |
| 885 | |
| 886 | if (destination_dir) |
| 887 | mz_path_combinecxx . . $ mz_path_combine(c42ad7cb79e2bab7).(path, destination_dir, resolved_name_size); |
| 888 | |
| 889 | mz_path_combinecxx . . $ mz_path_combine(c42ad7cb79e2bab7).(path, resolved_name, resolved_name_size); |
| 890 | |
| 891 | /* Save file to disk */ |
| 892 | err = mz_zip_reader_entry_save_filecxx . . $ mz_zip_reader_entry_save_file(f53b6be6549e6d95).(handle, path); |
| 893 | |
| 894 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 895 | err = mz_zip_reader_goto_next_entrycxx . . $ mz_zip_reader_goto_next_entry(dedf1e9b1c614a07).(handle); |
| 896 | } |
| 897 | |
| 898 | if (err == MZ_END_OF_LISTcxx . . $ `mz.h:28:9`!) |
| 899 | err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 900 | |
| 901 | save_all_cleanup: |
| 902 | freecxx . . $ free(5d22bdacc48458e8).(path); |
| 903 | freecxx . . $ free(5d22bdacc48458e8).(utf8_name); |
| 904 | freecxx . . $ free(5d22bdacc48458e8).(resolved_name); |
| 905 | |
| 906 | return err; |
| 907 | } |
| 908 | |
| 909 | /***************************************************************************/ |
| 910 | |
| 911 | void mz_zip_reader_set_patterncxx . . $ mz_zip_reader_set_pattern(1d6cee02e1406d75).(void *handle, const char *pattern, uint8_tcxx . . $ uint8_t# ignore_case) { |
| 912 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 913 | if (!reader) |
| 914 | return; |
| 915 | freecxx . . $ free(5d22bdacc48458e8).(reader->patterncxx . . $ mz_zip_reader_s#pattern.); |
| 916 | reader->patterncxx . . $ mz_zip_reader_s#pattern. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 917 | if (pattern) { |
| 918 | /* pattern can be NULL */ |
| 919 | int32_tcxx . . $ int32_t# pattern_size = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(pattern); |
| 920 | reader->patterncxx . . $ mz_zip_reader_s#pattern. = (char *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(pattern_size + 1, sizeof(char)); |
| 921 | if (!reader->patterncxx . . $ mz_zip_reader_s#pattern.) |
| 922 | /* Reference: `mz_zip_set_comment`, should return MZ_MEM_ERROR */ |
| 923 | return; |
| 924 | strncpycxx . . $ strncpy(255158a415b673b0).(reader->patterncxx . . $ mz_zip_reader_s#pattern., pattern, pattern_size); |
| 925 | } |
| 926 | reader->pattern_ignore_casecxx . . $ mz_zip_reader_s#pattern_ignore_case. = ignore_case; |
| 927 | } |
| 928 | |
| 929 | void mz_zip_reader_set_passwordcxx . . $ mz_zip_reader_set_password(e7c9eaecdb7c5ce7).(void *handle, const char *password) { |
| 930 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 931 | reader->passwordcxx . . $ mz_zip_reader_s#password. = password; |
| 932 | } |
| 933 | |
| 934 | void mz_zip_reader_set_rawcxx . . $ mz_zip_reader_set_raw(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# raw) { |
| 935 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 936 | reader->rawcxx . . $ mz_zip_reader_s#raw. = raw; |
| 937 | } |
| 938 | |
| 939 | int32_tcxx . . $ int32_t# mz_zip_reader_get_rawcxx . . $ mz_zip_reader_get_raw(1d53cd22b884299b).(void *handle, uint8_tcxx . . $ uint8_t# *raw) { |
| 940 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 941 | if (!raw) |
| 942 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 943 | *raw = reader->rawcxx . . $ mz_zip_reader_s#raw.; |
| 944 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 945 | } |
| 946 | |
| 947 | int32_tcxx . . $ int32_t# mz_zip_reader_get_zip_cdcxx . . $ mz_zip_reader_get_zip_cd(1d53cd22b884299b).(void *handle, uint8_tcxx . . $ uint8_t# *zip_cd) { |
| 948 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 949 | if (!zip_cd) |
| 950 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 951 | *zip_cd = reader->cd_zippedcxx . . $ mz_zip_reader_s#cd_zipped.; |
| 952 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 953 | } |
| 954 | |
| 955 | int32_tcxx . . $ int32_t# mz_zip_reader_get_commentcxx . . $ mz_zip_reader_get_comment(1160c33587cf46c5).(void *handle, const char **comment) { |
| 956 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 957 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 958 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 959 | if (!comment) |
| 960 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 961 | return mz_zip_get_commentcxx . . $ mz_zip_get_comment(1160c33587cf46c5).(reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle., comment); |
| 962 | } |
| 963 | |
| 964 | int32_tcxx . . $ int32_t# mz_zip_reader_set_recovercxx . . $ mz_zip_reader_set_recover(5276b51c10b71c09).(void *handle, uint8_tcxx . . $ uint8_t# recover) { |
| 965 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 966 | if (!reader) |
| 967 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 968 | reader->recovercxx . . $ mz_zip_reader_s#recover. = recover; |
| 969 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 970 | } |
| 971 | |
| 972 | void mz_zip_reader_set_encodingcxx . . $ mz_zip_reader_set_encoding(d0320739773070f2).(void *handle, int32_tcxx . . $ int32_t# encoding) { |
| 973 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 974 | reader->encodingcxx . . $ mz_zip_reader_s#encoding. = encoding; |
| 975 | } |
| 976 | |
| 977 | void mz_zip_reader_set_overwrite_cbcxx . . $ mz_zip_reader_set_overwrite_cb(6d9892e41fde2185).(void *handle, void *userdata, mz_zip_reader_overwrite_cbcxx . . $ mz_zip_reader_overwrite_cb# cb) { |
| 978 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 979 | reader->overwrite_cbcxx . . $ mz_zip_reader_s#overwrite_cb. = cb; |
| 980 | reader->overwrite_userdatacxx . . $ mz_zip_reader_s#overwrite_userdata. = userdata; |
| 981 | } |
| 982 | |
| 983 | void mz_zip_reader_set_password_cbcxx . . $ mz_zip_reader_set_password_cb(a8bb661fe5a7a48b).(void *handle, void *userdata, mz_zip_reader_password_cbcxx . . $ mz_zip_reader_password_cb# cb) { |
| 984 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 985 | reader->password_cbcxx . . $ mz_zip_reader_s#password_cb. = cb; |
| 986 | reader->password_userdatacxx . . $ mz_zip_reader_s#password_userdata. = userdata; |
| 987 | } |
| 988 | |
| 989 | void mz_zip_reader_set_progress_cbcxx . . $ mz_zip_reader_set_progress_cb(a176ec7de531be7e).(void *handle, void *userdata, mz_zip_reader_progress_cbcxx . . $ mz_zip_reader_progress_cb# cb) { |
| 990 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 991 | reader->progress_cbcxx . . $ mz_zip_reader_s#progress_cb. = cb; |
| 992 | reader->progress_userdatacxx . . $ mz_zip_reader_s#progress_userdata. = userdata; |
| 993 | } |
| 994 | |
| 995 | void mz_zip_reader_set_progress_intervalcxx . . $ mz_zip_reader_set_progress_interval(67abb4dd43ac34c5).(void *handle, uint32_tcxx . . $ uint32_t# milliseconds) { |
| 996 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 997 | reader->progress_cb_interval_mscxx . . $ mz_zip_reader_s#progress_cb_interval_ms. = milliseconds; |
| 998 | } |
| 999 | |
| 1000 | void mz_zip_reader_set_entry_cbcxx . . $ mz_zip_reader_set_entry_cb(6d9892e41fde2185).(void *handle, void *userdata, mz_zip_reader_entry_cbcxx . . $ mz_zip_reader_entry_cb# cb) { |
| 1001 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 1002 | reader->entry_cbcxx . . $ mz_zip_reader_s#entry_cb. = cb; |
| 1003 | reader->entry_userdatacxx . . $ mz_zip_reader_s#entry_userdata. = userdata; |
| 1004 | } |
| 1005 | |
| 1006 | int32_tcxx . . $ int32_t# mz_zip_reader_get_zip_handlecxx . . $ mz_zip_reader_get_zip_handle(1843ed636859e0d0).(void *handle, void **zip_handle) { |
| 1007 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)handle; |
| 1008 | if (!zip_handle) |
| 1009 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1010 | *zip_handle = reader->zip_handlecxx . . $ mz_zip_reader_s#zip_handle.; |
| 1011 | if (!*zip_handle) |
| 1012 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1013 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1014 | } |
| 1015 | |
| 1016 | /***************************************************************************/ |
| 1017 | |
| 1018 | void *mz_zip_reader_createcxx . . $ mz_zip_reader_create(50c7df7de5344ebb).(void) { |
| 1019 | mz_zip_readercxx . . $ mz_zip_reader# *reader = (mz_zip_readercxx . . $ mz_zip_reader# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(mz_zip_readercxx . . $ mz_zip_reader#)); |
| 1020 | if (reader) { |
| 1021 | reader->recovercxx . . $ mz_zip_reader_s#recover. = 1; |
| 1022 | reader->progress_cb_interval_mscxx . . $ mz_zip_reader_s#progress_cb_interval_ms. = MZ_DEFAULT_PROGRESS_INTERVALcxx . . $ `mz_zip_rw.c:26:9`!; |
| 1023 | } |
| 1024 | return reader; |
| 1025 | } |
| 1026 | |
| 1027 | void mz_zip_reader_deletecxx . . $ mz_zip_reader_delete(539e082cf00e1f43).(void **handle) { |
| 1028 | mz_zip_readercxx . . $ mz_zip_reader# *reader = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1029 | if (!handle) |
| 1030 | return; |
| 1031 | reader = (mz_zip_readercxx . . $ mz_zip_reader# *)*handle; |
| 1032 | if (reader) { |
| 1033 | mz_zip_reader_closecxx . . $ mz_zip_reader_close(dedf1e9b1c614a07).(reader); |
| 1034 | freecxx . . $ free(5d22bdacc48458e8).(reader); |
| 1035 | } |
| 1036 | *handle = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1037 | } |
| 1038 | |
| 1039 | /***************************************************************************/ |
| 1040 | |
| 1041 | typedef struct mz_zip_writer_scxx . . $ mz_zip_writer_s# { |
| 1042 | void *zip_handlecxx . . $ mz_zip_writer_s#zip_handle.; |
| 1043 | void *file_streamcxx . . $ mz_zip_writer_s#file_stream.; |
| 1044 | void *buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.; |
| 1045 | void *split_streamcxx . . $ mz_zip_writer_s#split_stream.; |
| 1046 | void *hashcxx . . $ mz_zip_writer_s#hash.; |
| 1047 | uint16_tcxx . . $ uint16_t# hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm.; |
| 1048 | void *mem_streamcxx . . $ mz_zip_writer_s#mem_stream.; |
| 1049 | void *file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream.; |
| 1050 | mz_zip_filecxx . . $ mz_zip_file# file_infocxx . . $ mz_zip_writer_s#file_info.; |
| 1051 | void *overwrite_userdatacxx . . $ mz_zip_writer_s#overwrite_userdata.; |
| 1052 | mz_zip_writer_overwrite_cbcxx . . $ mz_zip_writer_overwrite_cb# overwrite_cbcxx . . $ mz_zip_writer_s#overwrite_cb.; |
| 1053 | void *password_userdatacxx . . $ mz_zip_writer_s#password_userdata.; |
| 1054 | mz_zip_writer_password_cbcxx . . $ mz_zip_writer_password_cb# password_cbcxx . . $ mz_zip_writer_s#password_cb.; |
| 1055 | void *progress_userdatacxx . . $ mz_zip_writer_s#progress_userdata.; |
| 1056 | mz_zip_writer_progress_cbcxx . . $ mz_zip_writer_progress_cb# progress_cbcxx . . $ mz_zip_writer_s#progress_cb.; |
| 1057 | uint32_tcxx . . $ uint32_t# progress_cb_interval_mscxx . . $ mz_zip_writer_s#progress_cb_interval_ms.; |
| 1058 | void *entry_userdatacxx . . $ mz_zip_writer_s#entry_userdata.; |
| 1059 | mz_zip_writer_entry_cbcxx . . $ mz_zip_writer_entry_cb# entry_cbcxx . . $ mz_zip_writer_s#entry_cb.; |
| 1060 | const char *passwordcxx . . $ mz_zip_writer_s#password.; |
| 1061 | const char *commentcxx . . $ mz_zip_writer_s#comment.; |
| 1062 | uint16_tcxx . . $ uint16_t# compress_methodcxx . . $ mz_zip_writer_s#compress_method.; |
| 1063 | int16_tcxx . . $ int16_t# compress_levelcxx . . $ mz_zip_writer_s#compress_level.; |
| 1064 | uint8_tcxx . . $ uint8_t# follow_linkscxx . . $ mz_zip_writer_s#follow_links.; |
| 1065 | uint8_tcxx . . $ uint8_t# store_linkscxx . . $ mz_zip_writer_s#store_links.; |
| 1066 | uint8_tcxx . . $ uint8_t# zip_cdcxx . . $ mz_zip_writer_s#zip_cd.; |
| 1067 | uint8_tcxx . . $ uint8_t# aescxx . . $ mz_zip_writer_s#aes.; |
| 1068 | uint8_tcxx . . $ uint8_t# rawcxx . . $ mz_zip_writer_s#raw.; |
| 1069 | uint8_tcxx . . $ uint8_t# buffercxx . . $ mz_zip_writer_s#buffer.[UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!]; |
| 1070 | } mz_zip_writercxx . . $ mz_zip_writer#; |
| 1071 | |
| 1072 | /***************************************************************************/ |
| 1073 | |
| 1074 | int32_tcxx . . $ int32_t# mz_zip_writer_zip_cdcxx . . $ mz_zip_writer_zip_cd(dedf1e9b1c614a07).(void *handle) { |
| 1075 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1076 | mz_zip_filecxx . . $ mz_zip_file# cd_file; |
| 1077 | uint64_tcxx . . $ uint64_t# number_entry = 0; |
| 1078 | int64_tcxx . . $ int64_t# cd_mem_length = 0; |
| 1079 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1080 | int32_tcxx . . $ int32_t# extrafield_size = 0; |
| 1081 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1082 | void *cd_mem_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1083 | |
| 1084 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&cd_file, 0, sizeof(cd_file)); |
| 1085 | |
| 1086 | mz_zip_get_number_entrycxx . . $ mz_zip_get_number_entry(17c9a57913c314f0).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., &number_entry); |
| 1087 | mz_zip_get_cd_mem_streamcxx . . $ mz_zip_get_cd_mem_stream(1843ed636859e0d0).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., &cd_mem_stream); |
| 1088 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(cd_mem_stream, 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 1089 | cd_mem_length = (uint32_tcxx . . $ uint32_t#)mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(cd_mem_stream); |
| 1090 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(cd_mem_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1091 | |
| 1092 | cd_file.filenamecxx . . $ mz_zip_file_s#filename. = MZ_ZIP_CD_FILENAMEcxx . . $ `mz_zip_rw.c:28:9`!; |
| 1093 | cd_file.modified_datecxx . . $ mz_zip_file_s#modified_date. = timecxx . . $ time(7f38134db6521d23).(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 1094 | cd_file.version_madebycxx . . $ mz_zip_file_s#version_madeby. = MZ_VERSION_MADEBYcxx . . $ `mz_os.h:40:9`!; |
| 1095 | cd_file.compression_methodcxx . . $ mz_zip_file_s#compression_method. = writer->compress_methodcxx . . $ mz_zip_writer_s#compress_method.; |
| 1096 | cd_file.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = (int32_tcxx . . $ int32_t#)cd_mem_length; |
| 1097 | cd_file.flagcxx . . $ mz_zip_file_s#flag. = MZ_ZIP_FLAG_UTF8cxx . . $ `mz.h:84:9`!; |
| 1098 | |
| 1099 | if (writer->passwordcxx . . $ mz_zip_writer_s#password.) |
| 1100 | cd_file.flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!; |
| 1101 | |
| 1102 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1103 | if (!file_extra_stream) |
| 1104 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1105 | |
| 1106 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(file_extra_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1107 | |
| 1108 | mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(file_extra_stream, MZ_ZIP_EXTENSION_CDCDcxx . . $ `mz.h:94:9`!, 8); |
| 1109 | |
| 1110 | mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(file_extra_stream, number_entry); |
| 1111 | |
| 1112 | mz_stream_mem_get_buffercxx . . $ mz_stream_mem_get_buffer(d7fce53f66dcd9ef).(file_extra_stream, (const void **)&cd_file.extrafieldcxx . . $ mz_zip_file_s#extrafield.); |
| 1113 | mz_stream_mem_get_buffer_lengthcxx . . $ mz_stream_mem_get_buffer_length(6d7fe0143cf266f5).(file_extra_stream, &extrafield_size); |
| 1114 | cd_file.extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. = (uint16_tcxx . . $ uint16_t#)extrafield_size; |
| 1115 | |
| 1116 | err = mz_zip_writer_entry_opencxx . . $ mz_zip_writer_entry_open(d3c86492ca2a1ac4).(handle, &cd_file); |
| 1117 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1118 | mz_stream_copy_streamcxx . . $ mz_stream_copy_stream(956b84005340d103).(handle, mz_zip_writer_entry_writecxx . . $ mz_zip_writer_entry_write(91e54fd90adbb21)., cd_mem_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, (int32_tcxx . . $ int32_t#)cd_mem_length); |
| 1119 | |
| 1120 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(cd_mem_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1121 | mz_stream_mem_set_buffer_limitcxx . . $ mz_stream_mem_set_buffer_limit(d0320739773070f2).(cd_mem_stream, 0); |
| 1122 | |
| 1123 | err = mz_zip_writer_entry_closecxx . . $ mz_zip_writer_entry_close(dedf1e9b1c614a07).(writer); |
| 1124 | } |
| 1125 | |
| 1126 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 1127 | |
| 1128 | return err; |
| 1129 | } |
| 1130 | |
| 1131 | /***************************************************************************/ |
| 1132 | |
| 1133 | int32_tcxx . . $ int32_t# mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(void *handle) { |
| 1134 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1135 | if (!writer || !writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.) |
| 1136 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1137 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1138 | } |
| 1139 | |
| 1140 | static int32_tcxx . . $ int32_t# mz_zip_writer_open_intcxx . . $ mz_zip_writer_open_int(8bc41909eac9e5d8).(void *handle, void *stream, int32_tcxx . . $ int32_t# mode) { |
| 1141 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1142 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1143 | |
| 1144 | writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle. = mz_zip_createcxx . . $ mz_zip_create(50c7df7de5344ebb).(); |
| 1145 | if (writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle. == NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) |
| 1146 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1147 | |
| 1148 | err = mz_zip_opencxx . . $ mz_zip_open(8bc41909eac9e5d8).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., stream, mode); |
| 1149 | |
| 1150 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1151 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1152 | return err; |
| 1153 | } |
| 1154 | |
| 1155 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1156 | } |
| 1157 | |
| 1158 | int32_tcxx . . $ int32_t# mz_zip_writer_opencxx . . $ mz_zip_writer_open(a8ccb53ba7dd739d).(void *handle, void *stream, uint8_tcxx . . $ uint8_t# append) { |
| 1159 | int32_tcxx . . $ int32_t# mode = MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!; |
| 1160 | |
| 1161 | if (append) { |
| 1162 | mode |= MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!; |
| 1163 | } else { |
| 1164 | mode |= MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!; |
| 1165 | } |
| 1166 | |
| 1167 | return mz_zip_writer_open_intcxx . . $ mz_zip_writer_open_int(8bc41909eac9e5d8).(handle, stream, mode); |
| 1168 | } |
| 1169 | |
| 1170 | int32_tcxx . . $ int32_t# mz_zip_writer_open_filecxx . . $ mz_zip_writer_open_file(8d1f2bd428b9581c).(void *handle, const char *path, int64_tcxx . . $ int64_t# disk_size, uint8_tcxx . . $ uint8_t# append) { |
| 1171 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1172 | int32_tcxx . . $ int32_t# mode = MZ_OPEN_MODE_READWRITEcxx . . $ `mz.h:52:9`!; |
| 1173 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1174 | int32_tcxx . . $ int32_t# err_cb = 0; |
| 1175 | char directory[320]; |
| 1176 | |
| 1177 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1178 | |
| 1179 | if (mz_os_file_existscxx . . $ mz_os_file_exists(5c4306d8553b3696).(path) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1180 | /* If the file doesn't exist, we don't append file */ |
| 1181 | mode |= MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!; |
| 1182 | |
| 1183 | /* Create destination directory if it doesn't already exist */ |
| 1184 | if (strchrcxx . . $ strchr(2050848944e00d54).(path, '/') || strrchrcxx . . $ strrchr(2050848944e00d54).(path, '\\')) { |
| 1185 | strncpycxx . . $ strncpy(255158a415b673b0).(directory, path, sizeof(directory) - 1); |
| 1186 | directory[sizeof(directory) - 1] = 0; |
| 1187 | mz_path_remove_filenamecxx . . $ mz_path_remove_filename(1ef8e6ec083aabb9).(directory); |
| 1188 | if (mz_os_file_existscxx . . $ mz_os_file_exists(5c4306d8553b3696).(directory) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1189 | mz_dir_makecxx . . $ mz_dir_make(5c4306d8553b3696).(directory); |
| 1190 | } |
| 1191 | } else if (append) { |
| 1192 | mode |= MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!; |
| 1193 | } else { |
| 1194 | if (writer->overwrite_cbcxx . . $ mz_zip_writer_s#overwrite_cb.) |
| 1195 | err_cb = writer->overwrite_cbcxx . . $ mz_zip_writer_s#overwrite_cb.(handle, writer->overwrite_userdatacxx . . $ mz_zip_writer_s#overwrite_userdata., path); |
| 1196 | |
| 1197 | if (err_cb == MZ_INTERNAL_ERRORcxx . . $ `mz.h:33:9`!) |
| 1198 | return err; |
| 1199 | |
| 1200 | if (err_cb == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1201 | mode |= MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!; |
| 1202 | else |
| 1203 | mode |= MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!; |
| 1204 | } |
| 1205 | |
| 1206 | writer->file_streamcxx . . $ mz_zip_writer_s#file_stream. = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 1207 | if (!writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.) |
| 1208 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1209 | writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream. = mz_stream_buffered_createcxx . . $ mz_stream_buffered_create(50c7df7de5344ebb).(); |
| 1210 | if (!writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.) { |
| 1211 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.); |
| 1212 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1213 | } |
| 1214 | writer->split_streamcxx . . $ mz_zip_writer_s#split_stream. = mz_stream_split_createcxx . . $ mz_stream_split_create(50c7df7de5344ebb).(); |
| 1215 | if (!writer->split_streamcxx . . $ mz_zip_writer_s#split_stream.) { |
| 1216 | mz_stream_buffered_deletecxx . . $ mz_stream_buffered_delete(539e082cf00e1f43).(&writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.); |
| 1217 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.); |
| 1218 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1219 | } |
| 1220 | |
| 1221 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream., writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.); |
| 1222 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(writer->split_streamcxx . . $ mz_zip_writer_s#split_stream., writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.); |
| 1223 | |
| 1224 | mz_stream_split_set_prop_int64cxx . . $ mz_stream_split_set_prop_int64(5f4b2ff0df22ef2b).(writer->split_streamcxx . . $ mz_zip_writer_s#split_stream., MZ_STREAM_PROP_DISK_SIZEcxx . . $ `mz_strm.h:26:9`!, disk_size); |
| 1225 | |
| 1226 | err = mz_stream_opencxx . . $ mz_stream_open(7083a8984c0735e8).(writer->split_streamcxx . . $ mz_zip_writer_s#split_stream., path, mode); |
| 1227 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1228 | err = mz_zip_writer_open_intcxx . . $ mz_zip_writer_open_int(8bc41909eac9e5d8).(handle, writer->split_streamcxx . . $ mz_zip_writer_s#split_stream., mode); |
| 1229 | |
| 1230 | return err; |
| 1231 | } |
| 1232 | |
| 1233 | int32_tcxx . . $ int32_t# mz_zip_writer_open_file_in_memorycxx . . $ mz_zip_writer_open_file_in_memory(f53b6be6549e6d95).(void *handle, const char *path) { |
| 1234 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1235 | void *file_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1236 | int64_tcxx . . $ int64_t# file_size = 0; |
| 1237 | int32_tcxx . . $ int32_t# err = 0; |
| 1238 | |
| 1239 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1240 | |
| 1241 | file_stream = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 1242 | if (!file_stream) |
| 1243 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1244 | |
| 1245 | err = mz_stream_os_opencxx . . $ mz_stream_os_open(7083a8984c0735e8).(file_stream, path, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 1246 | |
| 1247 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1248 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 1249 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1250 | return err; |
| 1251 | } |
| 1252 | |
| 1253 | mz_stream_os_seekcxx . . $ mz_stream_os_seek(8bc0ff128761c75d).(file_stream, 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 1254 | file_size = mz_stream_os_tellcxx . . $ mz_stream_os_tell(72c1818a5177f981).(file_stream); |
| 1255 | mz_stream_os_seekcxx . . $ mz_stream_os_seek(8bc0ff128761c75d).(file_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1256 | writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1257 | |
| 1258 | if ((file_size <= 0) || (file_size > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) || (!writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream.)) { |
| 1259 | /* Memory size is too large or too small */ |
| 1260 | |
| 1261 | mz_stream_os_closecxx . . $ mz_stream_os_close(dedf1e9b1c614a07).(file_stream); |
| 1262 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 1263 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1264 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1265 | } |
| 1266 | |
| 1267 | mz_stream_mem_set_grow_sizecxx . . $ mz_stream_mem_set_grow_size(d0320739773070f2).(writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream., (int32_tcxx . . $ int32_t#)file_size); |
| 1268 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1269 | |
| 1270 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream., file_stream, (int32_tcxx . . $ int32_t#)file_size); |
| 1271 | |
| 1272 | mz_stream_os_closecxx . . $ mz_stream_os_close(dedf1e9b1c614a07).(file_stream); |
| 1273 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&file_stream); |
| 1274 | |
| 1275 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1276 | err = mz_zip_writer_opencxx . . $ mz_zip_writer_open(a8ccb53ba7dd739d).(handle, writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream., 1); |
| 1277 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1278 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(handle); |
| 1279 | |
| 1280 | return err; |
| 1281 | } |
| 1282 | |
| 1283 | int32_tcxx . . $ int32_t# mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(void *handle) { |
| 1284 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1285 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1286 | |
| 1287 | if (writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.) { |
| 1288 | mz_zip_set_version_madebycxx . . $ mz_zip_set_version_madeby(f805ef7ae580f896).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., MZ_VERSION_MADEBYcxx . . $ `mz_os.h:40:9`!); |
| 1289 | if (writer->commentcxx . . $ mz_zip_writer_s#comment.) |
| 1290 | mz_zip_set_commentcxx . . $ mz_zip_set_comment(f53b6be6549e6d95).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., writer->commentcxx . . $ mz_zip_writer_s#comment.); |
| 1291 | if (writer->zip_cdcxx . . $ mz_zip_writer_s#zip_cd.) |
| 1292 | mz_zip_writer_zip_cdcxx . . $ mz_zip_writer_zip_cd(dedf1e9b1c614a07).(writer); |
| 1293 | |
| 1294 | err = mz_zip_closecxx . . $ mz_zip_close(dedf1e9b1c614a07).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.); |
| 1295 | mz_zip_deletecxx . . $ mz_zip_delete(539e082cf00e1f43).(&writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.); |
| 1296 | } |
| 1297 | |
| 1298 | if (writer->split_streamcxx . . $ mz_zip_writer_s#split_stream.) { |
| 1299 | mz_stream_split_closecxx . . $ mz_stream_split_close(dedf1e9b1c614a07).(writer->split_streamcxx . . $ mz_zip_writer_s#split_stream.); |
| 1300 | mz_stream_split_deletecxx . . $ mz_stream_split_delete(539e082cf00e1f43).(&writer->split_streamcxx . . $ mz_zip_writer_s#split_stream.); |
| 1301 | } |
| 1302 | |
| 1303 | if (writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.) |
| 1304 | mz_stream_buffered_deletecxx . . $ mz_stream_buffered_delete(539e082cf00e1f43).(&writer->buffered_streamcxx . . $ mz_zip_writer_s#buffered_stream.); |
| 1305 | |
| 1306 | if (writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.) |
| 1307 | mz_stream_os_deletecxx . . $ mz_stream_os_delete(539e082cf00e1f43).(&writer->file_streamcxx . . $ mz_zip_writer_s#file_stream.); |
| 1308 | |
| 1309 | if (writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream.) { |
| 1310 | mz_stream_mem_closecxx . . $ mz_stream_mem_close(dedf1e9b1c614a07).(writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream.); |
| 1311 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&writer->mem_streamcxx . . $ mz_zip_writer_s#mem_stream.); |
| 1312 | } |
| 1313 | |
| 1314 | return err; |
| 1315 | } |
| 1316 | |
| 1317 | /***************************************************************************/ |
| 1318 | |
| 1319 | int32_tcxx . . $ int32_t# mz_zip_writer_entry_opencxx . . $ mz_zip_writer_entry_open(d3c86492ca2a1ac4).(void *handle, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 1320 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1321 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1322 | const char *password = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1323 | char password_buf[120]; |
| 1324 | |
| 1325 | /* Copy file info to access data upon close */ |
| 1326 | memcpycxx . . $ memcpy(cc817cb175f282d).(&writer->file_infocxx . . $ mz_zip_writer_s#file_info., file_info, sizeof(mz_zip_filecxx . . $ mz_zip_file#)); |
| 1327 | |
| 1328 | if (writer->entry_cbcxx . . $ mz_zip_writer_s#entry_cb.) |
| 1329 | writer->entry_cbcxx . . $ mz_zip_writer_s#entry_cb.(handle, writer->entry_userdatacxx . . $ mz_zip_writer_s#entry_userdata., &writer->file_infocxx . . $ mz_zip_writer_s#file_info.); |
| 1330 | |
| 1331 | password = writer->passwordcxx . . $ mz_zip_writer_s#password.; |
| 1332 | |
| 1333 | /* Check if we need a password and ask for it if we need to */ |
| 1334 | if (!password && writer->password_cbcxx . . $ mz_zip_writer_s#password_cb. && (writer->file_infocxx . . $ mz_zip_writer_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!)) { |
| 1335 | writer->password_cbcxx . . $ mz_zip_writer_s#password_cb.(handle, writer->password_userdatacxx . . $ mz_zip_writer_s#password_userdata., &writer->file_infocxx . . $ mz_zip_writer_s#file_info., password_buf, sizeof(password_buf)); |
| 1336 | password = password_buf; |
| 1337 | } |
| 1338 | |
| 1339 | #ifndef MZ_ZIP_NO_CRYPTO |
| 1340 | if (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(writer->file_infocxx . . $ mz_zip_writer_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., writer->file_infocxx . . $ mz_zip_writer_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1341 | /* Start calculating hash */ |
| 1342 | writer->hashcxx . . $ mz_zip_writer_s#hash. = mz_crypt_sha_createcxx . . $ mz_crypt_sha_create(50c7df7de5344ebb).(); |
| 1343 | writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm. = MZ_HASH_SHA256cxx . . $ `mz.h:131:9`!; |
| 1344 | if (!writer->hashcxx . . $ mz_zip_writer_s#hash.) |
| 1345 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1346 | err = mz_crypt_sha_set_algorithmcxx . . $ mz_crypt_sha_set_algorithm(f805ef7ae580f896).(writer->hashcxx . . $ mz_zip_writer_s#hash., writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm.); |
| 1347 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1348 | writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm. = MZ_HASH_SHA1cxx . . $ `mz.h:127:9`!; |
| 1349 | err = mz_crypt_sha_set_algorithmcxx . . $ mz_crypt_sha_set_algorithm(f805ef7ae580f896).(writer->hashcxx . . $ mz_zip_writer_s#hash., writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm.); |
| 1350 | } |
| 1351 | |
| 1352 | mz_crypt_sha_begincxx . . $ mz_crypt_sha_begin(dedf1e9b1c614a07).(writer->hashcxx . . $ mz_zip_writer_s#hash.); |
| 1353 | } |
| 1354 | #endif |
| 1355 | |
| 1356 | /* Open entry in zip */ |
| 1357 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1358 | err = mz_zip_entry_write_opencxx . . $ mz_zip_entry_write_open(20cb44e2e54ec293).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., &writer->file_infocxx . . $ mz_zip_writer_s#file_info., writer->compress_levelcxx . . $ mz_zip_writer_s#compress_level., writer->rawcxx . . $ mz_zip_writer_s#raw., |
| 1359 | password); |
| 1360 | } |
| 1361 | |
| 1362 | return err; |
| 1363 | } |
| 1364 | |
| 1365 | int32_tcxx . . $ int32_t# mz_zip_writer_entry_closecxx . . $ mz_zip_writer_entry_close(dedf1e9b1c614a07).(void *handle) { |
| 1366 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1367 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1368 | #ifndef MZ_ZIP_NO_CRYPTO |
| 1369 | const uint8_tcxx . . $ uint8_t# *extrafield = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1370 | int32_tcxx . . $ int32_t# extrafield_size = 0; |
| 1371 | int16_tcxx . . $ int16_t# field_length_hash = 0; |
| 1372 | uint8_tcxx . . $ uint8_t# hash_digest[MZ_HASH_MAX_SIZEcxx . . $ `mz.h:137:9`!]; |
| 1373 | |
| 1374 | if (writer->hashcxx . . $ mz_zip_writer_s#hash.) { |
| 1375 | uint16_tcxx . . $ uint16_t# hash_digest_size = 0; |
| 1376 | |
| 1377 | switch (writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm.) { |
| 1378 | case MZ_HASH_SHA1cxx . . $ `mz.h:127:9`!: |
| 1379 | hash_digest_size = MZ_HASH_SHA1_SIZEcxx . . $ `mz.h:128:9`!; |
| 1380 | break; |
| 1381 | case MZ_HASH_SHA256cxx . . $ `mz.h:131:9`!: |
| 1382 | hash_digest_size = MZ_HASH_SHA256_SIZEcxx . . $ `mz.h:132:9`!; |
| 1383 | break; |
| 1384 | default: |
| 1385 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1386 | } |
| 1387 | |
| 1388 | mz_crypt_sha_endcxx . . $ mz_crypt_sha_end(78b1a2a92e9cffd0).(writer->hashcxx . . $ mz_zip_writer_s#hash., hash_digest, hash_digest_size); |
| 1389 | mz_crypt_sha_deletecxx . . $ mz_crypt_sha_delete(539e082cf00e1f43).(&writer->hashcxx . . $ mz_zip_writer_s#hash.); |
| 1390 | |
| 1391 | /* Copy extrafield so we can append our own fields before close */ |
| 1392 | writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1393 | if (!writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream.) |
| 1394 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1395 | |
| 1396 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1397 | |
| 1398 | /* Write digest to extrafield */ |
| 1399 | field_length_hash = 4 + hash_digest_size; |
| 1400 | err = mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., MZ_ZIP_EXTENSION_HASHcxx . . $ `mz.h:93:9`!, field_length_hash); |
| 1401 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1402 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., writer->hash_algorithmcxx . . $ mz_zip_writer_s#hash_algorithm.); |
| 1403 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1404 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., hash_digest_size); |
| 1405 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1406 | if (mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., hash_digest, hash_digest_size) != hash_digest_size) |
| 1407 | err = MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 1408 | } |
| 1409 | |
| 1410 | if (writer->file_infocxx . . $ mz_zip_writer_s#file_info..extrafieldcxx . . $ mz_zip_file_s#extrafield. && writer->file_infocxx . . $ mz_zip_writer_s#file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. > 0) { |
| 1411 | mz_stream_mem_writecxx . . $ mz_stream_mem_write(91e54fd90adbb21).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., writer->file_infocxx . . $ mz_zip_writer_s#file_info..extrafieldcxx . . $ mz_zip_file_s#extrafield., |
| 1412 | writer->file_infocxx . . $ mz_zip_writer_s#file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 1413 | } |
| 1414 | |
| 1415 | /* Update extra field for central directory after adding extra fields */ |
| 1416 | mz_stream_mem_get_buffercxx . . $ mz_stream_mem_get_buffer(d7fce53f66dcd9ef).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., (const void **)&extrafield); |
| 1417 | mz_stream_mem_get_buffer_lengthcxx . . $ mz_stream_mem_get_buffer_length(6d7fe0143cf266f5).(writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream., &extrafield_size); |
| 1418 | |
| 1419 | mz_zip_entry_set_extrafieldcxx . . $ mz_zip_entry_set_extrafield(1048ced145d6ae0d).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., extrafield, (uint16_tcxx . . $ uint16_t#)extrafield_size); |
| 1420 | } |
| 1421 | #endif |
| 1422 | |
| 1423 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1424 | if (writer->rawcxx . . $ mz_zip_writer_s#raw.) |
| 1425 | err = |
| 1426 | mz_zip_entry_close_rawcxx . . $ mz_zip_entry_close_raw(85007a28ff75c5e5).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., writer->file_infocxx . . $ mz_zip_writer_s#file_info..uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size., writer->file_infocxx . . $ mz_zip_writer_s#file_info..crccxx . . $ mz_zip_file_s#crc.); |
| 1427 | else |
| 1428 | err = mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.); |
| 1429 | } |
| 1430 | |
| 1431 | if (writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream.) |
| 1432 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&writer->file_extra_streamcxx . . $ mz_zip_writer_s#file_extra_stream.); |
| 1433 | |
| 1434 | return err; |
| 1435 | } |
| 1436 | |
| 1437 | int32_tcxx . . $ int32_t# mz_zip_writer_entry_writecxx . . $ mz_zip_writer_entry_write(91e54fd90adbb21).(void *handle, const void *buf, int32_tcxx . . $ int32_t# len) { |
| 1438 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1439 | int32_tcxx . . $ int32_t# written = 0; |
| 1440 | written = mz_zip_entry_writecxx . . $ mz_zip_entry_write(91e54fd90adbb21).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle., buf, len); |
| 1441 | #ifndef MZ_ZIP_NO_CRYPTO |
| 1442 | if (written > 0 && writer->hashcxx . . $ mz_zip_writer_s#hash.) |
| 1443 | mz_crypt_sha_updatecxx . . $ mz_crypt_sha_update(91e54fd90adbb21).(writer->hashcxx . . $ mz_zip_writer_s#hash., buf, written); |
| 1444 | #endif |
| 1445 | return written; |
| 1446 | } |
| 1447 | /***************************************************************************/ |
| 1448 | |
| 1449 | int32_tcxx . . $ int32_t# mz_zip_writer_add_processcxx . . $ mz_zip_writer_add_process(af595b47575a036).(void *handle, void *stream, mz_stream_read_cbcxx . . $ mz_stream_read_cb# read_cb) { |
| 1450 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1451 | int32_tcxx . . $ int32_t# read = 0; |
| 1452 | int32_tcxx . . $ int32_t# written = 0; |
| 1453 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1454 | |
| 1455 | if (mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(writer) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1456 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1457 | /* If the entry isn't open for writing, open it */ |
| 1458 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1459 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1460 | if (!read_cb) |
| 1461 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1462 | |
| 1463 | read = read_cb(stream, writer->buffercxx . . $ mz_zip_writer_s#buffer., sizeof(writer->buffercxx . . $ mz_zip_writer_s#buffer.)); |
| 1464 | if (read == 0) |
| 1465 | return MZ_END_OF_STREAMcxx . . $ `mz.h:29:9`!; |
| 1466 | if (read < 0) { |
| 1467 | err = read; |
| 1468 | return err; |
| 1469 | } |
| 1470 | |
| 1471 | written = mz_zip_writer_entry_writecxx . . $ mz_zip_writer_entry_write(91e54fd90adbb21).(handle, writer->buffercxx . . $ mz_zip_writer_s#buffer., read); |
| 1472 | if (written != read) |
| 1473 | return MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 1474 | |
| 1475 | return written; |
| 1476 | } |
| 1477 | |
| 1478 | int32_tcxx . . $ int32_t# mz_zip_writer_addcxx . . $ mz_zip_writer_add(af595b47575a036).(void *handle, void *stream, mz_stream_read_cbcxx . . $ mz_stream_read_cb# read_cb) { |
| 1479 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1480 | uint64_tcxx . . $ uint64_t# current_time = 0; |
| 1481 | uint64_tcxx . . $ uint64_t# update_time = 0; |
| 1482 | int64_tcxx . . $ int64_t# current_pos = 0; |
| 1483 | int64_tcxx . . $ int64_t# update_pos = 0; |
| 1484 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1485 | int32_tcxx . . $ int32_t# written = 0; |
| 1486 | |
| 1487 | /* Update the progress at the beginning */ |
| 1488 | if (writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb.) |
| 1489 | writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb.(handle, writer->progress_userdatacxx . . $ mz_zip_writer_s#progress_userdata., &writer->file_infocxx . . $ mz_zip_writer_s#file_info., current_pos); |
| 1490 | |
| 1491 | /* Write data to stream until done */ |
| 1492 | while (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1493 | written = mz_zip_writer_add_processcxx . . $ mz_zip_writer_add_process(af595b47575a036).(handle, stream, read_cb); |
| 1494 | if (written == MZ_END_OF_STREAMcxx . . $ `mz.h:29:9`!) |
| 1495 | break; |
| 1496 | if (written > 0) |
| 1497 | current_pos += written; |
| 1498 | if (written < 0) |
| 1499 | err = written; |
| 1500 | |
| 1501 | /* Update progress if enough time have passed */ |
| 1502 | current_time = mz_os_ms_timecxx . . $ mz_os_ms_time(f708dce9a8856c70).(); |
| 1503 | if ((current_time - update_time) > writer->progress_cb_interval_mscxx . . $ mz_zip_writer_s#progress_cb_interval_ms.) { |
| 1504 | if (writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb.) |
| 1505 | writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb.(handle, writer->progress_userdatacxx . . $ mz_zip_writer_s#progress_userdata., &writer->file_infocxx . . $ mz_zip_writer_s#file_info., current_pos); |
| 1506 | |
| 1507 | update_pos = current_pos; |
| 1508 | update_time = current_time; |
| 1509 | } |
| 1510 | } |
| 1511 | |
| 1512 | /* Update the progress at the end */ |
| 1513 | if (writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb. && update_pos != current_pos) |
| 1514 | writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb.(handle, writer->progress_userdatacxx . . $ mz_zip_writer_s#progress_userdata., &writer->file_infocxx . . $ mz_zip_writer_s#file_info., current_pos); |
| 1515 | |
| 1516 | return err; |
| 1517 | } |
| 1518 | |
| 1519 | int32_tcxx . . $ int32_t# mz_zip_writer_add_infocxx . . $ mz_zip_writer_add_info(9d7843d9d92591da).(void *handle, void *stream, mz_stream_read_cbcxx . . $ mz_stream_read_cb# read_cb, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 1520 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1521 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1522 | |
| 1523 | if (mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1524 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1525 | if (!file_info) |
| 1526 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1527 | |
| 1528 | /* Add to zip */ |
| 1529 | err = mz_zip_writer_entry_opencxx . . $ mz_zip_writer_entry_open(d3c86492ca2a1ac4).(handle, file_info); |
| 1530 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1531 | return err; |
| 1532 | |
| 1533 | if (stream) { |
| 1534 | if (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(writer->file_infocxx . . $ mz_zip_writer_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., writer->file_infocxx . . $ mz_zip_writer_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1535 | err = mz_zip_writer_addcxx . . $ mz_zip_writer_add(af595b47575a036).(handle, stream, read_cb); |
| 1536 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1537 | return err; |
| 1538 | } |
| 1539 | } |
| 1540 | |
| 1541 | err = mz_zip_writer_entry_closecxx . . $ mz_zip_writer_entry_close(dedf1e9b1c614a07).(handle); |
| 1542 | |
| 1543 | return err; |
| 1544 | } |
| 1545 | |
| 1546 | int32_tcxx . . $ int32_t# mz_zip_writer_add_buffercxx . . $ mz_zip_writer_add_buffer(13855b87aa2c129f).(void *handle, void *buf, int32_tcxx . . $ int32_t# len, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 1547 | void *mem_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1548 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1549 | |
| 1550 | if (mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1551 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1552 | if (!buf) |
| 1553 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1554 | |
| 1555 | /* Create a memory stream backed by our buffer and add from it */ |
| 1556 | mem_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1557 | if (!mem_stream) |
| 1558 | return MZ_STREAM_ERRORcxx . . $ `mz.h:22:9`!; |
| 1559 | |
| 1560 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(mem_stream, buf, len); |
| 1561 | |
| 1562 | err = mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(mem_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 1563 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1564 | err = mz_zip_writer_add_infocxx . . $ mz_zip_writer_add_info(9d7843d9d92591da).(handle, mem_stream, mz_stream_mem_readcxx . . $ mz_stream_mem_read(8bc41909eac9e5d8)., file_info); |
| 1565 | |
| 1566 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&mem_stream); |
| 1567 | return err; |
| 1568 | } |
| 1569 | |
| 1570 | int32_tcxx . . $ int32_t# mz_zip_writer_add_filecxx . . $ mz_zip_writer_add_file(fb385f74881b8076).(void *handle, const char *path, const char *filename_in_zip) { |
| 1571 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1572 | mz_zip_filecxx . . $ mz_zip_file# file_info; |
| 1573 | uint32_tcxx . . $ uint32_t# target_attrib = 0; |
| 1574 | uint32_tcxx . . $ uint32_t# src_attrib = 0; |
| 1575 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1576 | uint8_tcxx . . $ uint8_t# src_sys = 0; |
| 1577 | void *stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1578 | char link_path[1024]; |
| 1579 | const char *filename = filename_in_zip; |
| 1580 | |
| 1581 | if (mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1582 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1583 | if (!path) |
| 1584 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1585 | |
| 1586 | if (!filename) { |
| 1587 | err = mz_path_get_filenamecxx . . $ mz_path_get_filename(2ef3bc9ee8f8b3e9).(path, &filename); |
| 1588 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1589 | return err; |
| 1590 | } |
| 1591 | |
| 1592 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&file_info, 0, sizeof(file_info)); |
| 1593 | |
| 1594 | /* The path name saved, should not include a leading slash. */ |
| 1595 | /* If it did, windows/xp and dynazip couldn't read the zip file. */ |
| 1596 | |
| 1597 | while (filename[0] == '\\' || filename[0] == '/') |
| 1598 | filename += 1; |
| 1599 | |
| 1600 | /* Get information about the file on disk so we can store it in zip */ |
| 1601 | |
| 1602 | file_info.version_madebycxx . . $ mz_zip_file_s#version_madeby. = MZ_VERSION_MADEBYcxx . . $ `mz_os.h:40:9`!; |
| 1603 | file_info.compression_methodcxx . . $ mz_zip_file_s#compression_method. = writer->compress_methodcxx . . $ mz_zip_writer_s#compress_method.; |
| 1604 | file_info.filenamecxx . . $ mz_zip_file_s#filename. = filename; |
| 1605 | file_info.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = mz_os_get_file_sizecxx . . $ mz_os_get_file_size(3c95bd14d5d5d286).(path); |
| 1606 | file_info.flagcxx . . $ mz_zip_file_s#flag. = MZ_ZIP_FLAG_UTF8cxx . . $ `mz.h:84:9`!; |
| 1607 | |
| 1608 | if (writer->zip_cdcxx . . $ mz_zip_writer_s#zip_cd.) |
| 1609 | file_info.flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_MASK_LOCAL_INFOcxx . . $ `mz.h:85:9`!; |
| 1610 | if (writer->aescxx . . $ mz_zip_writer_s#aes.) |
| 1611 | file_info.aes_versioncxx . . $ mz_zip_file_s#aes_version. = MZ_AES_VERSIONcxx . . $ `mz.h:113:9`!; |
| 1612 | |
| 1613 | mz_os_get_file_datecxx . . $ mz_os_get_file_date(d6a2abb5a2f53069).(path, &file_info.modified_datecxx . . $ mz_zip_file_s#modified_date., &file_info.accessed_datecxx . . $ mz_zip_file_s#accessed_date., &file_info.creation_datecxx . . $ mz_zip_file_s#creation_date.); |
| 1614 | mz_os_get_file_attribscxx . . $ mz_os_get_file_attribs(6974107818eeb505).(path, &src_attrib); |
| 1615 | |
| 1616 | src_sys = MZ_HOST_SYSTEMcxx . . $ `mz.h:102:9`!(file_info.version_madeby); |
| 1617 | |
| 1618 | if ((src_sys != MZ_HOST_SYSTEM_MSDOScxx . . $ `mz.h:103:9`!) && (src_sys != MZ_HOST_SYSTEM_WINDOWS_NTFScxx . . $ `mz.h:105:9`!)) { |
| 1619 | /* High bytes are OS specific attributes, low byte is always DOS attributes */ |
| 1620 | if (mz_zip_attrib_convertcxx . . $ mz_zip_attrib_convert(20c6f379b34f0b73).(src_sys, src_attrib, MZ_HOST_SYSTEM_MSDOScxx . . $ `mz.h:103:9`!, &target_attrib) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1621 | file_info.external_facxx . . $ mz_zip_file_s#external_fa. = target_attrib; |
| 1622 | file_info.external_facxx . . $ mz_zip_file_s#external_fa. |= (src_attrib << 16); |
| 1623 | } else { |
| 1624 | file_info.external_facxx . . $ mz_zip_file_s#external_fa. = src_attrib; |
| 1625 | } |
| 1626 | |
| 1627 | if (writer->store_linkscxx . . $ mz_zip_writer_s#store_links. && mz_os_is_symlinkcxx . . $ mz_os_is_symlink(5c4306d8553b3696).(path) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1628 | err = mz_os_read_symlinkcxx . . $ mz_os_read_symlink(89c8e27db0bdb94e).(path, link_path, sizeof(link_path)); |
| 1629 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1630 | file_info.linknamecxx . . $ mz_zip_file_s#linkname. = link_path; |
| 1631 | } else if (mz_os_is_dircxx . . $ mz_os_is_dir(5c4306d8553b3696).(path) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1632 | stream = mz_stream_os_createcxx . . $ mz_stream_os_create(50c7df7de5344ebb).(); |
| 1633 | if (!stream) |
| 1634 | return MZ_STREAM_ERRORcxx . . $ `mz.h:22:9`!; |
| 1635 | err = mz_stream_os_opencxx . . $ mz_stream_os_open(7083a8984c0735e8).(stream, path, MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!); |
| 1636 | } |
| 1637 | |
| 1638 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1639 | err = mz_zip_writer_add_infocxx . . $ mz_zip_writer_add_info(9d7843d9d92591da).(handle, stream, mz_stream_readcxx . . $ mz_stream_read(8bc41909eac9e5d8)., &file_info); |
| 1640 | |
| 1641 | if (stream) { |
| 1642 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(stream); |
| 1643 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&stream); |
| 1644 | } |
| 1645 | |
| 1646 | return err; |
| 1647 | } |
| 1648 | |
| 1649 | int32_tcxx . . $ int32_t# mz_zip_writer_add_pathcxx . . $ mz_zip_writer_add_path(56f4f039cb04742b).(void *handle, const char *path, const char *root_path, uint8_tcxx . . $ uint8_t# include_path, |
| 1650 | uint8_tcxx . . $ uint8_t# recursive) { |
| 1651 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1652 | DIRcxx . . $ DIR# *dir = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1653 | struct direntcxx . . $ dirent# *entry = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1654 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1655 | int16_tcxx . . $ int16_t# is_dir = 0; |
| 1656 | const char *filename = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1657 | const char *filenameinzip = path; |
| 1658 | char *wildcard_ptr = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1659 | char full_path[1024]; |
| 1660 | char path_dir[1024]; |
| 1661 | |
| 1662 | if (strrchrcxx . . $ strrchr(2050848944e00d54).(path, '*') && mz_os_file_existscxx . . $ mz_os_file_exists(5c4306d8553b3696).(path) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1663 | strncpycxx . . $ strncpy(255158a415b673b0).(path_dir, path, sizeof(path_dir) - 1); |
| 1664 | path_dir[sizeof(path_dir) - 1] = 0; |
| 1665 | mz_path_remove_filenamecxx . . $ mz_path_remove_filename(1ef8e6ec083aabb9).(path_dir); |
| 1666 | wildcard_ptr = path_dir + strlencxx . . $ strlen(751346f8406fd082).(path_dir) + 1; |
| 1667 | root_path = path = path_dir; |
| 1668 | } else { |
| 1669 | if (mz_os_is_dircxx . . $ mz_os_is_dir(5c4306d8553b3696).(path) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1670 | is_dir = 1; |
| 1671 | |
| 1672 | /* Construct the filename that our file will be stored in the zip as */ |
| 1673 | if (!root_path) |
| 1674 | root_path = path; |
| 1675 | |
| 1676 | /* Should the file be stored with any path info at all? */ |
| 1677 | if (!include_path) { |
| 1678 | if (!is_dir && root_path == path) { |
| 1679 | if (mz_path_get_filenamecxx . . $ mz_path_get_filename(2ef3bc9ee8f8b3e9).(filenameinzip, &filename) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1680 | filenameinzip = filename; |
| 1681 | } else { |
| 1682 | filenameinzip += strlencxx . . $ strlen(751346f8406fd082).(root_path); |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | if (!writer->store_linkscxx . . $ mz_zip_writer_s#store_links. && !writer->follow_linkscxx . . $ mz_zip_writer_s#follow_links.) { |
| 1687 | if (mz_os_is_symlinkcxx . . $ mz_os_is_symlink(5c4306d8553b3696).(path) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1688 | return err; |
| 1689 | } |
| 1690 | |
| 1691 | if (*filenameinzip != 0) |
| 1692 | err = mz_zip_writer_add_filecxx . . $ mz_zip_writer_add_file(fb385f74881b8076).(handle, path, filenameinzip); |
| 1693 | |
| 1694 | if (!is_dir) |
| 1695 | return err; |
| 1696 | |
| 1697 | if (writer->store_linkscxx . . $ mz_zip_writer_s#store_links.) { |
| 1698 | if (mz_os_is_symlinkcxx . . $ mz_os_is_symlink(5c4306d8553b3696).(path) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1699 | return err; |
| 1700 | } |
| 1701 | } |
| 1702 | |
| 1703 | dir = mz_os_open_dircxx . . $ mz_os_open_dir(f465d4b65cec8dd2).(path); |
| 1704 | |
| 1705 | if (!dir) |
| 1706 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1707 | |
| 1708 | while ((entry = mz_os_read_dircxx . . $ mz_os_read_dir(ffbaae344e1a615a).(dir))) { |
| 1709 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(entry->d_namecxx . . $ dirent#d_name., ".") == 0 || strcmpcxx . . $ strcmp(5ae29d726ae57f88).(entry->d_namecxx . . $ dirent#d_name., "..") == 0) |
| 1710 | continue; |
| 1711 | |
| 1712 | full_path[0] = 0; |
| 1713 | mz_path_combinecxx . . $ mz_path_combine(c42ad7cb79e2bab7).(full_path, path, sizeof(full_path)); |
| 1714 | mz_path_combinecxx . . $ mz_path_combine(c42ad7cb79e2bab7).(full_path, entry->d_namecxx . . $ dirent#d_name., sizeof(full_path)); |
| 1715 | |
| 1716 | if (!recursive && mz_os_is_dircxx . . $ mz_os_is_dir(5c4306d8553b3696).(full_path) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1717 | continue; |
| 1718 | |
| 1719 | if ((wildcard_ptr) && (mz_path_compare_wccxx . . $ mz_path_compare_wc(6dbe66b8d729cbab).(entry->d_namecxx . . $ dirent#d_name., wildcard_ptr, 1) != MZ_OKcxx . . $ `mz.h:21:9`!)) |
| 1720 | continue; |
| 1721 | |
| 1722 | err = mz_zip_writer_add_pathcxx . . $ mz_zip_writer_add_path(56f4f039cb04742b).(handle, full_path, root_path, include_path, recursive); |
| 1723 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1724 | break; |
| 1725 | } |
| 1726 | |
| 1727 | mz_os_close_dircxx . . $ mz_os_close_dir(ac30a447bc7c2f80).(dir); |
| 1728 | return err; |
| 1729 | } |
| 1730 | |
| 1731 | int32_tcxx . . $ int32_t# mz_zip_writer_copy_from_readercxx . . $ mz_zip_writer_copy_from_reader(361d5d7064a2a85d).(void *handle, void *reader) { |
| 1732 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1733 | mz_zip_filecxx . . $ mz_zip_file# *file_info = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1734 | int64_tcxx . . $ int64_t# compressed_size = 0; |
| 1735 | int64_tcxx . . $ int64_t# uncompressed_size = 0; |
| 1736 | uint32_tcxx . . $ uint32_t# crc32 = 0; |
| 1737 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1738 | uint8_tcxx . . $ uint8_t# original_raw = 0; |
| 1739 | void *reader_zip_handle = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1740 | void *writer_zip_handle = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1741 | |
| 1742 | if (mz_zip_reader_is_opencxx . . $ mz_zip_reader_is_open(dedf1e9b1c614a07).(reader) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1743 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1744 | if (mz_zip_writer_is_opencxx . . $ mz_zip_writer_is_open(dedf1e9b1c614a07).(writer) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1745 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1746 | |
| 1747 | err = mz_zip_reader_entry_get_infocxx . . $ mz_zip_reader_entry_get_info(4dd5ee9bdbc1d978).(reader, &file_info); |
| 1748 | |
| 1749 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1750 | return err; |
| 1751 | |
| 1752 | mz_zip_reader_get_zip_handlecxx . . $ mz_zip_reader_get_zip_handle(1843ed636859e0d0).(reader, &reader_zip_handle); |
| 1753 | mz_zip_writer_get_zip_handlecxx . . $ mz_zip_writer_get_zip_handle(1843ed636859e0d0).(writer, &writer_zip_handle); |
| 1754 | |
| 1755 | /* Open entry for raw reading */ |
| 1756 | err = mz_zip_entry_read_opencxx . . $ mz_zip_entry_read_open(5e2f72b4b9a4e6c4).(reader_zip_handle, 1, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 1757 | |
| 1758 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1759 | /* Write entry raw, save original raw value */ |
| 1760 | original_raw = writer->rawcxx . . $ mz_zip_writer_s#raw.; |
| 1761 | writer->rawcxx . . $ mz_zip_writer_s#raw. = 1; |
| 1762 | |
| 1763 | err = mz_zip_writer_entry_opencxx . . $ mz_zip_writer_entry_open(d3c86492ca2a1ac4).(writer, file_info); |
| 1764 | |
| 1765 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && |
| 1766 | (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(writer->file_infocxx . . $ mz_zip_writer_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., writer->file_infocxx . . $ mz_zip_writer_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) != MZ_OKcxx . . $ `mz.h:21:9`!)) { |
| 1767 | err = mz_zip_writer_addcxx . . $ mz_zip_writer_add(af595b47575a036).(writer, reader_zip_handle, mz_zip_entry_readcxx . . $ mz_zip_entry_read(8bc41909eac9e5d8).); |
| 1768 | } |
| 1769 | |
| 1770 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1771 | err = mz_zip_entry_read_closecxx . . $ mz_zip_entry_read_close(f358a56cc8c9350).(reader_zip_handle, &crc32, &compressed_size, &uncompressed_size); |
| 1772 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1773 | err = mz_zip_entry_write_closecxx . . $ mz_zip_entry_write_close(b4f223597101ed9a).(writer_zip_handle, crc32, compressed_size, uncompressed_size); |
| 1774 | } |
| 1775 | |
| 1776 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(reader_zip_handle) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1777 | mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(reader_zip_handle); |
| 1778 | |
| 1779 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(writer_zip_handle) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1780 | mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(writer_zip_handle); |
| 1781 | |
| 1782 | #ifndef MZ_ZIP_NO_CRYPTO |
| 1783 | mz_crypt_sha_deletecxx . . $ mz_crypt_sha_delete(539e082cf00e1f43).(&writer->hashcxx . . $ mz_zip_writer_s#hash.); |
| 1784 | #endif |
| 1785 | |
| 1786 | writer->rawcxx . . $ mz_zip_writer_s#raw. = original_raw; |
| 1787 | } |
| 1788 | |
| 1789 | return err; |
| 1790 | } |
| 1791 | |
| 1792 | /***************************************************************************/ |
| 1793 | |
| 1794 | void mz_zip_writer_set_passwordcxx . . $ mz_zip_writer_set_password(e7c9eaecdb7c5ce7).(void *handle, const char *password) { |
| 1795 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1796 | writer->passwordcxx . . $ mz_zip_writer_s#password. = password; |
| 1797 | } |
| 1798 | |
| 1799 | void mz_zip_writer_set_commentcxx . . $ mz_zip_writer_set_comment(e7c9eaecdb7c5ce7).(void *handle, const char *comment) { |
| 1800 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1801 | writer->commentcxx . . $ mz_zip_writer_s#comment. = comment; |
| 1802 | } |
| 1803 | |
| 1804 | void mz_zip_writer_set_rawcxx . . $ mz_zip_writer_set_raw(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# raw) { |
| 1805 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1806 | writer->rawcxx . . $ mz_zip_writer_s#raw. = raw; |
| 1807 | } |
| 1808 | |
| 1809 | int32_tcxx . . $ int32_t# mz_zip_writer_get_rawcxx . . $ mz_zip_writer_get_raw(1d53cd22b884299b).(void *handle, uint8_tcxx . . $ uint8_t# *raw) { |
| 1810 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1811 | if (!raw) |
| 1812 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1813 | *raw = writer->rawcxx . . $ mz_zip_writer_s#raw.; |
| 1814 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1815 | } |
| 1816 | |
| 1817 | void mz_zip_writer_set_aescxx . . $ mz_zip_writer_set_aes(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# aes) { |
| 1818 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1819 | writer->aescxx . . $ mz_zip_writer_s#aes. = aes; |
| 1820 | } |
| 1821 | |
| 1822 | void mz_zip_writer_set_compress_methodcxx . . $ mz_zip_writer_set_compress_method(7ff71eb16271959b).(void *handle, uint16_tcxx . . $ uint16_t# compress_method) { |
| 1823 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1824 | writer->compress_methodcxx . . $ mz_zip_writer_s#compress_method. = compress_method; |
| 1825 | } |
| 1826 | |
| 1827 | void mz_zip_writer_set_compress_levelcxx . . $ mz_zip_writer_set_compress_level(2dc42f898b1399ca).(void *handle, int16_tcxx . . $ int16_t# compress_level) { |
| 1828 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1829 | writer->compress_levelcxx . . $ mz_zip_writer_s#compress_level. = compress_level; |
| 1830 | } |
| 1831 | |
| 1832 | void mz_zip_writer_set_follow_linkscxx . . $ mz_zip_writer_set_follow_links(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# follow_links) { |
| 1833 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1834 | writer->follow_linkscxx . . $ mz_zip_writer_s#follow_links. = follow_links; |
| 1835 | } |
| 1836 | |
| 1837 | void mz_zip_writer_set_store_linkscxx . . $ mz_zip_writer_set_store_links(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# store_links) { |
| 1838 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1839 | writer->store_linkscxx . . $ mz_zip_writer_s#store_links. = store_links; |
| 1840 | } |
| 1841 | |
| 1842 | void mz_zip_writer_set_zip_cdcxx . . $ mz_zip_writer_set_zip_cd(5b3d32ff749dfd74).(void *handle, uint8_tcxx . . $ uint8_t# zip_cd) { |
| 1843 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1844 | writer->zip_cdcxx . . $ mz_zip_writer_s#zip_cd. = zip_cd; |
| 1845 | } |
| 1846 | |
| 1847 | void mz_zip_writer_set_overwrite_cbcxx . . $ mz_zip_writer_set_overwrite_cb(4f0896f64a06e504).(void *handle, void *userdata, mz_zip_writer_overwrite_cbcxx . . $ mz_zip_writer_overwrite_cb# cb) { |
| 1848 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1849 | writer->overwrite_cbcxx . . $ mz_zip_writer_s#overwrite_cb. = cb; |
| 1850 | writer->overwrite_userdatacxx . . $ mz_zip_writer_s#overwrite_userdata. = userdata; |
| 1851 | } |
| 1852 | |
| 1853 | void mz_zip_writer_set_password_cbcxx . . $ mz_zip_writer_set_password_cb(a8bb661fe5a7a48b).(void *handle, void *userdata, mz_zip_writer_password_cbcxx . . $ mz_zip_writer_password_cb# cb) { |
| 1854 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1855 | writer->password_cbcxx . . $ mz_zip_writer_s#password_cb. = cb; |
| 1856 | writer->password_userdatacxx . . $ mz_zip_writer_s#password_userdata. = userdata; |
| 1857 | } |
| 1858 | |
| 1859 | void mz_zip_writer_set_progress_cbcxx . . $ mz_zip_writer_set_progress_cb(a176ec7de531be7e).(void *handle, void *userdata, mz_zip_writer_progress_cbcxx . . $ mz_zip_writer_progress_cb# cb) { |
| 1860 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1861 | writer->progress_cbcxx . . $ mz_zip_writer_s#progress_cb. = cb; |
| 1862 | writer->progress_userdatacxx . . $ mz_zip_writer_s#progress_userdata. = userdata; |
| 1863 | } |
| 1864 | |
| 1865 | void mz_zip_writer_set_progress_intervalcxx . . $ mz_zip_writer_set_progress_interval(67abb4dd43ac34c5).(void *handle, uint32_tcxx . . $ uint32_t# milliseconds) { |
| 1866 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1867 | writer->progress_cb_interval_mscxx . . $ mz_zip_writer_s#progress_cb_interval_ms. = milliseconds; |
| 1868 | } |
| 1869 | |
| 1870 | void mz_zip_writer_set_entry_cbcxx . . $ mz_zip_writer_set_entry_cb(13f30cfb96cfcf2b).(void *handle, void *userdata, mz_zip_writer_entry_cbcxx . . $ mz_zip_writer_entry_cb# cb) { |
| 1871 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1872 | writer->entry_cbcxx . . $ mz_zip_writer_s#entry_cb. = cb; |
| 1873 | writer->entry_userdatacxx . . $ mz_zip_writer_s#entry_userdata. = userdata; |
| 1874 | } |
| 1875 | |
| 1876 | int32_tcxx . . $ int32_t# mz_zip_writer_get_zip_handlecxx . . $ mz_zip_writer_get_zip_handle(1843ed636859e0d0).(void *handle, void **zip_handle) { |
| 1877 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)handle; |
| 1878 | if (!zip_handle) |
| 1879 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1880 | *zip_handle = writer->zip_handlecxx . . $ mz_zip_writer_s#zip_handle.; |
| 1881 | if (!*zip_handle) |
| 1882 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1883 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1884 | } |
| 1885 | |
| 1886 | /***************************************************************************/ |
| 1887 | |
| 1888 | void *mz_zip_writer_createcxx . . $ mz_zip_writer_create(50c7df7de5344ebb).(void) { |
| 1889 | mz_zip_writercxx . . $ mz_zip_writer# *writer = (mz_zip_writercxx . . $ mz_zip_writer# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(mz_zip_writercxx . . $ mz_zip_writer#)); |
| 1890 | if (writer) { |
| 1891 | #if defined(HAVE_WZAEScxx . . $ `<built-in>:416:9`!) |
| 1892 | writer->aescxx . . $ mz_zip_writer_s#aes. = 1; |
| 1893 | #endif |
| 1894 | #if defined(HAVE_ZLIBcxx . . $ `<built-in>:417:9`!) || defined(HAVE_LIBCOMP) |
| 1895 | writer->compress_methodcxx . . $ mz_zip_writer_s#compress_method. = MZ_COMPRESS_METHOD_DEFLATEcxx . . $ `mz.h:64:9`!; |
| 1896 | #elif defined(HAVE_BZIP2) |
| 1897 | writer->compress_method = MZ_COMPRESS_METHOD_BZIP2; |
| 1898 | #elif defined(HAVE_LZMA) |
| 1899 | writer->compress_method = MZ_COMPRESS_METHOD_LZMA; |
| 1900 | #else |
| 1901 | writer->compress_method = MZ_COMPRESS_METHOD_STORE; |
| 1902 | #endif |
| 1903 | writer->compress_levelcxx . . $ mz_zip_writer_s#compress_level. = MZ_COMPRESS_LEVEL_BESTcxx . . $ `mz.h:74:9`!; |
| 1904 | writer->progress_cb_interval_mscxx . . $ mz_zip_writer_s#progress_cb_interval_ms. = MZ_DEFAULT_PROGRESS_INTERVALcxx . . $ `mz_zip_rw.c:26:9`!; |
| 1905 | } |
| 1906 | return writer; |
| 1907 | } |
| 1908 | |
| 1909 | void mz_zip_writer_deletecxx . . $ mz_zip_writer_delete(539e082cf00e1f43).(void **handle) { |
| 1910 | mz_zip_writercxx . . $ mz_zip_writer# *writer = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1911 | if (!handle) |
| 1912 | return; |
| 1913 | writer = (mz_zip_writercxx . . $ mz_zip_writer# *)*handle; |
| 1914 | if (writer) { |
| 1915 | mz_zip_writer_closecxx . . $ mz_zip_writer_close(dedf1e9b1c614a07).(writer); |
| 1916 | freecxx . . $ free(5d22bdacc48458e8).(writer); |
| 1917 | } |
| 1918 | *handle = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1919 | } |
| 1920 | |
| 1921 | /***************************************************************************/ |