| 1 | /* zip.c -- Zip manipulation |
| 2 | part of the minizip-ng project |
| 3 | |
| 4 | Copyright (C) Nathan Moinvaziri |
| 5 | https://github.com/zlib-ng/minizip-ng |
| 6 | Copyright (C) 2009-2010 Mathias Svensson |
| 7 | Modifications for Zip64 support |
| 8 | http://result42.com |
| 9 | Copyright (C) 2007-2008 Even Rouault |
| 10 | Modifications of Unzip for Zip64 |
| 11 | Copyright (C) 1998-2010 Gilles Vollant |
| 12 | https://www.winimage.com/zLibDll/minizip.html |
| 13 | |
| 14 | This program is distributed under the terms of the same license as zlib. |
| 15 | See the accompanying LICENSE file for the full text of the license. |
| 16 | */ |
| 17 | |
| 18 | #include "mz.h"cxx . . $ `<file>/mz.h`/ |
| 19 | #include "mz_crypt.h"cxx . . $ `<file>/mz_crypt.h`/ |
| 20 | #include "mz_os.h"cxx . . $ `<file>/mz_os.h`/ |
| 21 | #include "mz_strm.h"cxx . . $ `<file>/mz_strm.h`/ |
| 22 | #ifdef HAVE_BZIP2 |
| 23 | # include "mz_strm_bzip.h" |
| 24 | #endif |
| 25 | #ifdef HAVE_LIBCOMP |
| 26 | # include "mz_strm_libcomp.h" |
| 27 | #endif |
| 28 | #ifdef HAVE_LZMA |
| 29 | # include "mz_strm_lzma.h" |
| 30 | #endif |
| 31 | #include "mz_strm_mem.h"cxx . . $ `<file>/mz_strm_mem.h`/ |
| 32 | #ifdef HAVE_PKCRYPTcxx . . $ `<built-in>:414:9`! |
| 33 | # include "mz_strm_pkcrypt.h"cxx . . $ `<file>/mz_strm_pkcrypt.h`/ |
| 34 | #endif |
| 35 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 36 | # include "mz_strm_wzaes.h"cxx . . $ `<file>/mz_strm_wzaes.h`/ |
| 37 | #endif |
| 38 | #ifdef HAVE_ZLIBcxx . . $ `<built-in>:417:9`! |
| 39 | # include "mz_strm_zlib.h"cxx . . $ `<file>/mz_strm_zlib.h`/ |
| 40 | #endif |
| 41 | #ifdef HAVE_ZSTD |
| 42 | # include "mz_strm_zstd.h" |
| 43 | #endif |
| 44 | |
| 45 | #include "mz_zip.h"cxx . . $ `<file>/mz_zip.h`/ |
| 46 | |
| 47 | #include <ctype.h> /* tolower */ |
| 48 | #include <stdio.h> /* snprintf */ |
| 49 | |
| 50 | #if defined(_MSC_VER) || defined(__MINGW32__) |
| 51 | # define localtime_r(t1, t2) (localtime_s(t2, t1) == 0 ? t1 : NULL) |
| 52 | #endif |
| 53 | #if defined(_MSC_VER) && (_MSC_VER < 1900) |
| 54 | # define snprintf _snprintf |
| 55 | #endif |
| 56 | |
| 57 | /***************************************************************************/ |
| 58 | |
| 59 | #define MZ_ZIP_MAGIC_LOCALHEADERcxx . . $ `mz_zip.c:59:9`! (0x04034b50) |
| 60 | #define MZ_ZIP_MAGIC_LOCALHEADERU8cxx . . $ `mz_zip.c:60:9`! {0x50, 0x4b, 0x03, 0x04} |
| 61 | #define MZ_ZIP_MAGIC_CENTRALHEADERcxx . . $ `mz_zip.c:61:9`! (0x02014b50) |
| 62 | #define MZ_ZIP_MAGIC_CENTRALHEADERU8cxx . . $ `mz_zip.c:62:9`! {0x50, 0x4b, 0x01, 0x02} |
| 63 | #define MZ_ZIP_MAGIC_ENDHEADERcxx . . $ `mz_zip.c:63:9`! (0x06054b50) |
| 64 | #define MZ_ZIP_MAGIC_ENDHEADERU8cxx . . $ `mz_zip.c:64:9`! {0x50, 0x4b, 0x05, 0x06} |
| 65 | #define MZ_ZIP_MAGIC_ENDHEADER64cxx . . $ `mz_zip.c:65:9`! (0x06064b50) |
| 66 | #define MZ_ZIP_MAGIC_ENDLOCHEADER64cxx . . $ `mz_zip.c:66:9`! (0x07064b50) |
| 67 | #define MZ_ZIP_MAGIC_DATADESCRIPTORcxx . . $ `mz_zip.c:67:9`! (0x08074b50) |
| 68 | #define MZ_ZIP_MAGIC_DATADESCRIPTORU8cxx . . $ `mz_zip.c:68:9`! {0x50, 0x4b, 0x07, 0x08} |
| 69 | |
| 70 | #define MZ_ZIP_SIZE_LD_ITEMcxx . . $ `mz_zip.c:70:9`! (30) |
| 71 | #define MZ_ZIP_SIZE_CD_ITEMcxx . . $ `mz_zip.c:71:9`! (46) |
| 72 | #define MZ_ZIP_SIZE_CD_LOCATOR64cxx . . $ `mz_zip.c:72:9`! (20) |
| 73 | #define MZ_ZIP_SIZE_MAX_DATA_DESCRIPTORcxx . . $ `mz_zip.c:73:9`! (24) |
| 74 | |
| 75 | #define MZ_ZIP_OFFSET_CRC_SIZEScxx . . $ `mz_zip.c:75:9`! (14) |
| 76 | #define MZ_ZIP_UNCOMPR_SIZE64_CUSHIONcxx . . $ `mz_zip.c:76:9`! (2 * 1024 * 1024) |
| 77 | |
| 78 | #ifndef MZ_ZIP_EOCD_MAX_BACK |
| 79 | # define MZ_ZIP_EOCD_MAX_BACKcxx . . $ `mz_zip.c:79:11`! (1 << 20) |
| 80 | #endif |
| 81 | |
| 82 | /***************************************************************************/ |
| 83 | |
| 84 | typedef struct mz_zip_scxx . . $ mz_zip_s# { |
| 85 | mz_zip_filecxx . . $ mz_zip_file# file_infocxx . . $ mz_zip_s#file_info.; |
| 86 | mz_zip_filecxx . . $ mz_zip_file# local_file_infocxx . . $ mz_zip_s#local_file_info.; |
| 87 | |
| 88 | void *streamcxx . . $ mz_zip_s#stream.; /* main stream */ |
| 89 | void *cd_streamcxx . . $ mz_zip_s#cd_stream.; /* pointer to the stream with the cd */ |
| 90 | void *cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.; /* memory stream for central directory */ |
| 91 | void *compress_streamcxx . . $ mz_zip_s#compress_stream.; /* compression stream */ |
| 92 | void *crypt_streamcxx . . $ mz_zip_s#crypt_stream.; /* encryption stream */ |
| 93 | void *file_info_streamcxx . . $ mz_zip_s#file_info_stream.; /* memory stream for storing file info */ |
| 94 | void *local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.; /* memory stream for storing local file info */ |
| 95 | |
| 96 | int32_tcxx . . $ int32_t# open_modecxx . . $ mz_zip_s#open_mode.; |
| 97 | uint8_tcxx . . $ uint8_t# recovercxx . . $ mz_zip_s#recover.; |
| 98 | uint8_tcxx . . $ uint8_t# data_descriptorcxx . . $ mz_zip_s#data_descriptor.; |
| 99 | |
| 100 | uint32_tcxx . . $ uint32_t# disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.; /* number of the disk with the central dir */ |
| 101 | int64_tcxx . . $ int64_t# disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift.; /* correction for zips that have wrong offset start of cd */ |
| 102 | |
| 103 | int64_tcxx . . $ int64_t# cd_start_poscxx . . $ mz_zip_s#cd_start_pos.; /* pos of the first file in the central dir stream */ |
| 104 | int64_tcxx . . $ int64_t# cd_current_poscxx . . $ mz_zip_s#cd_current_pos.; /* pos of the current file in the central dir */ |
| 105 | int64_tcxx . . $ int64_t# cd_offsetcxx . . $ mz_zip_s#cd_offset.; /* offset of start of central directory */ |
| 106 | int64_tcxx . . $ int64_t# cd_sizecxx . . $ mz_zip_s#cd_size.; /* size of the central directory */ |
| 107 | uint32_tcxx . . $ uint32_t# cd_signaturecxx . . $ mz_zip_s#cd_signature.; /* signature of central directory */ |
| 108 | |
| 109 | uint8_tcxx . . $ uint8_t# entry_scannedcxx . . $ mz_zip_s#entry_scanned.; /* entry header information read ok */ |
| 110 | uint8_tcxx . . $ uint8_t# entry_openedcxx . . $ mz_zip_s#entry_opened.; /* entry is open for read/write */ |
| 111 | uint8_tcxx . . $ uint8_t# entry_rawcxx . . $ mz_zip_s#entry_raw.; /* entry opened with raw mode */ |
| 112 | uint32_tcxx . . $ uint32_t# entry_crc32cxx . . $ mz_zip_s#entry_crc32.; /* entry crc32 */ |
| 113 | |
| 114 | uint64_tcxx . . $ uint64_t# number_entrycxx . . $ mz_zip_s#number_entry.; |
| 115 | |
| 116 | uint16_tcxx . . $ uint16_t# version_madebycxx . . $ mz_zip_s#version_madeby.; |
| 117 | char *commentcxx . . $ mz_zip_s#comment.; |
| 118 | } mz_zipcxx . . $ mz_zip#; |
| 119 | |
| 120 | /***************************************************************************/ |
| 121 | |
| 122 | #if 0 |
| 123 | # define mz_zip_print printf |
| 124 | #else |
| 125 | # define mz_zip_printcxx . . $ `mz_zip.c:125:11`!(fmt, ...) |
| 126 | #endif |
| 127 | |
| 128 | /***************************************************************************/ |
| 129 | |
| 130 | /* Locate the end of central directory */ |
| 131 | static int32_tcxx . . $ int32_t# mz_zip_search_eocdcxx . . $ mz_zip_search_eocd(3c3380c49b0234ac).(void *stream, int64_tcxx . . $ int64_t# *central_pos) { |
| 132 | int64_tcxx . . $ int64_t# file_size = 0; |
| 133 | int64_tcxx . . $ int64_t# max_back = MZ_ZIP_EOCD_MAX_BACKcxx . . $ `mz_zip.c:79:11`!; |
| 134 | uint8_tcxx . . $ uint8_t# find[4] = MZ_ZIP_MAGIC_ENDHEADERU8cxx . . $ `mz_zip.c:64:9`!; |
| 135 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 136 | |
| 137 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(stream, 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 138 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 139 | return err; |
| 140 | |
| 141 | file_size = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(stream); |
| 142 | |
| 143 | if (max_back <= 0 || max_back > file_size) |
| 144 | max_back = file_size; |
| 145 | |
| 146 | return mz_stream_find_reversecxx . . $ mz_stream_find_reverse(8aa461340cfae934).(stream, (const void *)find, sizeof(find), max_back, central_pos); |
| 147 | } |
| 148 | |
| 149 | /* Locate the end of central directory 64 of a zip file */ |
| 150 | static int32_tcxx . . $ int32_t# mz_zip_search_zip64_eocdcxx . . $ mz_zip_search_zip64_eocd(98b7c25805f7791).(void *stream, const int64_tcxx . . $ int64_t# end_central_offset, int64_tcxx . . $ int64_t# *central_pos) { |
| 151 | int64_tcxx . . $ int64_t# offset = 0; |
| 152 | uint32_tcxx . . $ uint32_t# value32 = 0; |
| 153 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 154 | |
| 155 | *central_pos = 0; |
| 156 | |
| 157 | /* Zip64 end of central directory locator */ |
| 158 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(stream, end_central_offset - MZ_ZIP_SIZE_CD_LOCATOR64cxx . . $ `mz_zip.c:72:9`!, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 159 | /* Read locator signature */ |
| 160 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 161 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 162 | if (value32 != MZ_ZIP_MAGIC_ENDLOCHEADER64cxx . . $ `mz_zip.c:66:9`!) |
| 163 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 164 | } |
| 165 | /* Number of the disk with the start of the zip64 end of central directory */ |
| 166 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 167 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 168 | /* Relative offset of the zip64 end of central directory record8 */ |
| 169 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 170 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(stream, (uint64_tcxx . . $ uint64_t# *)&offset); |
| 171 | /* Total number of disks */ |
| 172 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 173 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 174 | /* Goto end of central directory record */ |
| 175 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 176 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(stream, (int64_tcxx . . $ int64_t#)offset, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 177 | /* The signature */ |
| 178 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 179 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 180 | if (value32 != MZ_ZIP_MAGIC_ENDHEADER64cxx . . $ `mz_zip.c:65:9`!) |
| 181 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 182 | } |
| 183 | |
| 184 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 185 | *central_pos = offset; |
| 186 | |
| 187 | return err; |
| 188 | } |
| 189 | |
| 190 | #ifdef HAVE_PKCRYPTcxx . . $ `<built-in>:414:9`! |
| 191 | /* Get PKWARE traditional encryption verifier */ |
| 192 | static uint16_tcxx . . $ uint16_t# mz_zip_get_pk_verifycxx . . $ mz_zip_get_pk_verify(ff658ccb6c36c729).(uint32_tcxx . . $ uint32_t# dos_date, uint64_tcxx . . $ uint64_t# crc, uint16_tcxx . . $ uint16_t# flag) { |
| 193 | /* Info-ZIP modification to ZipCrypto format: if bit 3 of the general |
| 194 | * purpose bit flag is set, it uses high byte of 16-bit File Time. */ |
| 195 | if (flag & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!) |
| 196 | return ((dos_date >> 16) & 0xff) << 8 | ((dos_date >> 8) & 0xff); |
| 197 | return ((crc >> 16) & 0xff) << 8 | ((crc >> 24) & 0xff); |
| 198 | } |
| 199 | #endif |
| 200 | |
| 201 | /* Get info about the current file in the zip file */ |
| 202 | static int32_tcxx . . $ int32_t# mz_zip_entry_read_headercxx . . $ mz_zip_entry_read_header(22e9f4de044eb2c0).(void *stream, uint8_tcxx . . $ uint8_t# local, mz_zip_filecxx . . $ mz_zip_file# *file_info, void *file_extra_stream) { |
| 203 | uint64_tcxx . . $ uint64_t# ntfs_time = 0; |
| 204 | uint32_tcxx . . $ uint32_t# reserved = 0; |
| 205 | uint32_tcxx . . $ uint32_t# magic = 0; |
| 206 | uint32_tcxx . . $ uint32_t# dos_date = 0; |
| 207 | uint32_tcxx . . $ uint32_t# field_pos = 0; |
| 208 | uint16_tcxx . . $ uint16_t# field_type = 0; |
| 209 | uint16_tcxx . . $ uint16_t# field_length = 0; |
| 210 | uint32_tcxx . . $ uint32_t# field_length_read = 0; |
| 211 | uint16_tcxx . . $ uint16_t# ntfs_attrib_id = 0; |
| 212 | uint16_tcxx . . $ uint16_t# ntfs_attrib_size = 0; |
| 213 | uint16_tcxx . . $ uint16_t# linkname_size; |
| 214 | uint16_tcxx . . $ uint16_t# value16 = 0; |
| 215 | uint32_tcxx . . $ uint32_t# value32 = 0; |
| 216 | int64_tcxx . . $ int64_t# extrafield_pos = 0; |
| 217 | int64_tcxx . . $ int64_t# comment_pos = 0; |
| 218 | int64_tcxx . . $ int64_t# linkname_pos = 0; |
| 219 | int64_tcxx . . $ int64_t# saved_pos = 0; |
| 220 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 221 | char *linkname = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 222 | |
| 223 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(file_info, 0, sizeof(mz_zip_filecxx . . $ mz_zip_file#)); |
| 224 | |
| 225 | /* Check the magic */ |
| 226 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &magic); |
| 227 | if (err == MZ_END_OF_STREAMcxx . . $ `mz.h:29:9`!) |
| 228 | err = MZ_END_OF_LISTcxx . . $ `mz.h:28:9`!; |
| 229 | else if (magic == MZ_ZIP_MAGIC_ENDHEADERcxx . . $ `mz_zip.c:63:9`! || magic == MZ_ZIP_MAGIC_ENDHEADER64cxx . . $ `mz_zip.c:65:9`!) |
| 230 | err = MZ_END_OF_LISTcxx . . $ `mz.h:28:9`!; |
| 231 | else if ((local) && (magic != MZ_ZIP_MAGIC_LOCALHEADERcxx . . $ `mz_zip.c:59:9`!)) |
| 232 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 233 | else if ((!local) && (magic != MZ_ZIP_MAGIC_CENTRALHEADERcxx . . $ `mz_zip.c:61:9`!)) |
| 234 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 235 | |
| 236 | /* Read header fields */ |
| 237 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 238 | if (!local) |
| 239 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->version_madebycxx . . $ mz_zip_file_s#version_madeby.); |
| 240 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 241 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->version_neededcxx . . $ mz_zip_file_s#version_needed.); |
| 242 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 243 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->flagcxx . . $ mz_zip_file_s#flag.); |
| 244 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 245 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->compression_methodcxx . . $ mz_zip_file_s#compression_method.); |
| 246 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 247 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &dos_date); |
| 248 | file_info->modified_datecxx . . $ mz_zip_file_s#modified_date. = mz_zip_dosdate_to_time_tcxx . . $ mz_zip_dosdate_to_time_t(f7e21917e59627ec).(dos_date); |
| 249 | } |
| 250 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 251 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &file_info->crccxx . . $ mz_zip_file_s#crc.); |
| 252 | #ifdef HAVE_PKCRYPTcxx . . $ `<built-in>:414:9`! |
| 253 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) { |
| 254 | /* Use dos_date from header instead of derived from time in zip extensions */ |
| 255 | file_info->pk_verifycxx . . $ mz_zip_file_s#pk_verify. = mz_zip_get_pk_verifycxx . . $ mz_zip_get_pk_verify(ff658ccb6c36c729).(dos_date, file_info->crccxx . . $ mz_zip_file_s#crc., file_info->flagcxx . . $ mz_zip_file_s#flag.); |
| 256 | } |
| 257 | #endif |
| 258 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 259 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 260 | file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size. = value32; |
| 261 | } |
| 262 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 263 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 264 | file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = value32; |
| 265 | } |
| 266 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 267 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->filename_sizecxx . . $ mz_zip_file_s#filename_size.); |
| 268 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 269 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 270 | if (!local) { |
| 271 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 272 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size.); |
| 273 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 274 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &value16); |
| 275 | file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number. = value16; |
| 276 | } |
| 277 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 278 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &file_info->internal_facxx . . $ mz_zip_file_s#internal_fa.); |
| 279 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 280 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &file_info->external_facxx . . $ mz_zip_file_s#external_fa.); |
| 281 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 282 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 283 | file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. = value32; |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 289 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 290 | |
| 291 | /* Copy variable length data to memory stream for later retrieval */ |
| 292 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->filename_sizecxx . . $ mz_zip_file_s#filename_size. > 0)) |
| 293 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(file_extra_stream, stream, file_info->filename_sizecxx . . $ mz_zip_file_s#filename_size.); |
| 294 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(file_extra_stream, 0); |
| 295 | extrafield_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(file_extra_stream); |
| 296 | |
| 297 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. > 0)) |
| 298 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(file_extra_stream, stream, file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 299 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(file_extra_stream, 0); |
| 300 | |
| 301 | comment_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(file_extra_stream); |
| 302 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size. > 0)) |
| 303 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(file_extra_stream, stream, file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size.); |
| 304 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(file_extra_stream, 0); |
| 305 | |
| 306 | linkname_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(file_extra_stream); |
| 307 | /* Overwrite if we encounter UNIX1 extra block */ |
| 308 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(file_extra_stream, 0); |
| 309 | |
| 310 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. > 0)) { |
| 311 | /* Seek to and parse the extra field */ |
| 312 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, extrafield_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 313 | |
| 314 | while ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (field_pos + 4 <= file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.)) { |
| 315 | err = mz_zip_extrafield_readcxx . . $ mz_zip_extrafield_read(9a4a45287d8af1f7).(file_extra_stream, &field_type, &field_length); |
| 316 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 317 | break; |
| 318 | field_pos += 4; |
| 319 | |
| 320 | /* Don't allow field length to exceed size of remaining extrafield */ |
| 321 | if (field_length > (file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. - field_pos)) |
| 322 | field_length = (uint16_tcxx . . $ uint16_t#)(file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. - field_pos); |
| 323 | |
| 324 | /* Read ZIP64 extra field */ |
| 325 | if ((field_type == MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`!) && (field_length >= 8)) { |
| 326 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. == UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) { |
| 327 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(file_extra_stream, &file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 328 | if (file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. < 0) |
| 329 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 330 | } |
| 331 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size. == UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) { |
| 332 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(file_extra_stream, &file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size.); |
| 333 | if (file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size. < 0) |
| 334 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 335 | } |
| 336 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. == UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) { |
| 337 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(file_extra_stream, &file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset.); |
| 338 | if (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. < 0) |
| 339 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 340 | } |
| 341 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number. == UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!)) |
| 342 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(file_extra_stream, &file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number.); |
| 343 | } |
| 344 | /* Read NTFS extra field */ |
| 345 | else if ((field_type == MZ_ZIP_EXTENSION_NTFScxx . . $ `mz.h:89:9`!) && (field_length > 4)) { |
| 346 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 347 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(file_extra_stream, &reserved); |
| 348 | field_length_read = 4; |
| 349 | |
| 350 | while ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (field_length_read + 4 <= field_length)) { |
| 351 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &ntfs_attrib_id); |
| 352 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 353 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &ntfs_attrib_size); |
| 354 | field_length_read += 4; |
| 355 | |
| 356 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (ntfs_attrib_id == 0x01) && (ntfs_attrib_size == 24)) { |
| 357 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(file_extra_stream, &ntfs_time); |
| 358 | mz_zip_ntfs_to_unix_timecxx . . $ mz_zip_ntfs_to_unix_time(c11a4b583e983ba5).(ntfs_time, &file_info->modified_datecxx . . $ mz_zip_file_s#modified_date.); |
| 359 | |
| 360 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 361 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(file_extra_stream, &ntfs_time); |
| 362 | mz_zip_ntfs_to_unix_timecxx . . $ mz_zip_ntfs_to_unix_time(c11a4b583e983ba5).(ntfs_time, &file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date.); |
| 363 | } |
| 364 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 365 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(file_extra_stream, &ntfs_time); |
| 366 | mz_zip_ntfs_to_unix_timecxx . . $ mz_zip_ntfs_to_unix_time(c11a4b583e983ba5).(ntfs_time, &file_info->creation_datecxx . . $ mz_zip_file_s#creation_date.); |
| 367 | } |
| 368 | } else if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (field_length_read + ntfs_attrib_size <= field_length)) { |
| 369 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, ntfs_attrib_size, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 370 | } |
| 371 | |
| 372 | field_length_read += ntfs_attrib_size; |
| 373 | } |
| 374 | } |
| 375 | /* Read UNIX1 extra field */ |
| 376 | else if ((field_type == MZ_ZIP_EXTENSION_UNIX1cxx . . $ `mz.h:91:9`!) && (field_length >= 12)) { |
| 377 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 378 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(file_extra_stream, &value32); |
| 379 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date. == 0) |
| 380 | file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date. = value32; |
| 381 | } |
| 382 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 383 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(file_extra_stream, &value32); |
| 384 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && file_info->modified_datecxx . . $ mz_zip_file_s#modified_date. == 0) |
| 385 | file_info->modified_datecxx . . $ mz_zip_file_s#modified_date. = value32; |
| 386 | } |
| 387 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 388 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &value16); /* User id */ |
| 389 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 390 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &value16); /* Group id */ |
| 391 | |
| 392 | /* Copy linkname to end of file extra stream so we can return null |
| 393 | terminated string */ |
| 394 | linkname_size = field_length - 12; |
| 395 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (linkname_size > 0)) { |
| 396 | linkname = (char *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(linkname_size); |
| 397 | if (linkname) { |
| 398 | if (mz_stream_readcxx . . $ mz_stream_read(8bc41909eac9e5d8).(file_extra_stream, linkname, linkname_size) != linkname_size) |
| 399 | err = MZ_READ_ERRORcxx . . $ `mz.h:44:9`!; |
| 400 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 401 | saved_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(file_extra_stream); |
| 402 | |
| 403 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, linkname_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 404 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(file_extra_stream, linkname, linkname_size); |
| 405 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(file_extra_stream, 0); |
| 406 | |
| 407 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, saved_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 408 | } |
| 409 | freecxx . . $ free(5d22bdacc48458e8).(linkname); |
| 410 | } |
| 411 | } |
| 412 | } |
| 413 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 414 | /* Read AES extra field */ |
| 415 | else if ((field_type == MZ_ZIP_EXTENSION_AEScxx . . $ `mz.h:90:9`!) && (field_length == 7)) { |
| 416 | uint8_tcxx . . $ uint8_t# value8 = 0; |
| 417 | /* Verify version info */ |
| 418 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &value16); |
| 419 | /* Support AE-1 and AE-2 */ |
| 420 | if (value16 != 1 && value16 != 2) |
| 421 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 422 | file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version. = value16; |
| 423 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 424 | err = mz_stream_read_uint8cxx . . $ mz_stream_read_uint8(1d53cd22b884299b).(file_extra_stream, &value8); |
| 425 | if ((char)value8 != 'A') |
| 426 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 427 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 428 | err = mz_stream_read_uint8cxx . . $ mz_stream_read_uint8(1d53cd22b884299b).(file_extra_stream, &value8); |
| 429 | if ((char)value8 != 'E') |
| 430 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 431 | /* Get AES encryption strength and actual compression method */ |
| 432 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 433 | err = mz_stream_read_uint8cxx . . $ mz_stream_read_uint8(1d53cd22b884299b).(file_extra_stream, &value8); |
| 434 | file_info->aes_strengthcxx . . $ mz_zip_file_s#aes_strength. = value8; |
| 435 | } |
| 436 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 437 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &value16); |
| 438 | file_info->compression_methodcxx . . $ mz_zip_file_s#compression_method. = value16; |
| 439 | } |
| 440 | } |
| 441 | #endif |
| 442 | else if (field_length > 0) { |
| 443 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, field_length, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 444 | } |
| 445 | |
| 446 | field_pos += field_length; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | /* Get pointers to variable length data */ |
| 451 | mz_stream_mem_get_buffercxx . . $ mz_stream_mem_get_buffer(d7fce53f66dcd9ef).(file_extra_stream, (const void **)&file_info->filenamecxx . . $ mz_zip_file_s#filename.); |
| 452 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(file_extra_stream, extrafield_pos, (const void **)&file_info->extrafieldcxx . . $ mz_zip_file_s#extrafield.); |
| 453 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(file_extra_stream, comment_pos, (const void **)&file_info->commentcxx . . $ mz_zip_file_s#comment.); |
| 454 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(file_extra_stream, linkname_pos, (const void **)&file_info->linknamecxx . . $ mz_zip_file_s#linkname.); |
| 455 | |
| 456 | /* Set to empty string just in-case */ |
| 457 | if (!file_info->filenamecxx . . $ mz_zip_file_s#filename.) |
| 458 | file_info->filenamecxx . . $ mz_zip_file_s#filename. = ""; |
| 459 | if (!file_info->extrafieldcxx . . $ mz_zip_file_s#extrafield.) |
| 460 | file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. = 0; |
| 461 | if (!file_info->commentcxx . . $ mz_zip_file_s#comment.) |
| 462 | file_info->commentcxx . . $ mz_zip_file_s#comment. = ""; |
| 463 | if (!file_info->linknamecxx . . $ mz_zip_file_s#linkname.) |
| 464 | file_info->linknamecxx . . $ mz_zip_file_s#linkname. = ""; |
| 465 | |
| 466 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 467 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read header - %s (local %" PRId8 ")\n", file_info->filename, local); |
| 468 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read header compress (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", |
| 469 | file_info->uncompressed_size, file_info->compressed_size, file_info->crc); |
| 470 | if (!local) { |
| 471 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read header disk (disk %" PRIu32 " offset %" PRId64 ")\n", |
| 472 | file_info->disk_number, file_info->disk_offset); |
| 473 | } |
| 474 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read header variable (fnl %" PRId32 " efs %" PRId32 " cms %" PRId32 ")\n", |
| 475 | file_info->filename_size, file_info->extrafield_size, file_info->comment_size); |
| 476 | } |
| 477 | |
| 478 | return err; |
| 479 | } |
| 480 | |
| 481 | static int32_tcxx . . $ int32_t# mz_zip_entry_read_descriptorcxx . . $ mz_zip_entry_read_descriptor(f7c6753e6a4e27a9).(void *stream, uint8_tcxx . . $ uint8_t# zip64, uint32_tcxx . . $ uint32_t# *crc32, int64_tcxx . . $ int64_t# *compressed_size, |
| 482 | int64_tcxx . . $ int64_t# *uncompressed_size) { |
| 483 | uint32_tcxx . . $ uint32_t# value32 = 0; |
| 484 | int64_tcxx . . $ int64_t# value64 = 0; |
| 485 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 486 | |
| 487 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 488 | if (value32 != MZ_ZIP_MAGIC_DATADESCRIPTORcxx . . $ `mz_zip.c:67:9`!) |
| 489 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 490 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 491 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 492 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && crc32) |
| 493 | *crc32 = value32; |
| 494 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 495 | /* If zip 64 extension is enabled then read as 8 byte */ |
| 496 | if (!zip64) { |
| 497 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 498 | value64 = value32; |
| 499 | } else { |
| 500 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(stream, &value64); |
| 501 | if (value64 < 0) |
| 502 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 503 | } |
| 504 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && compressed_size) |
| 505 | *compressed_size = value64; |
| 506 | } |
| 507 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 508 | if (!zip64) { |
| 509 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(stream, &value32); |
| 510 | value64 = value32; |
| 511 | } else { |
| 512 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(stream, &value64); |
| 513 | if (value64 < 0) |
| 514 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 515 | } |
| 516 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && uncompressed_size) |
| 517 | *uncompressed_size = value64; |
| 518 | } |
| 519 | |
| 520 | return err; |
| 521 | } |
| 522 | |
| 523 | static int32_tcxx . . $ int32_t# mz_zip_entry_write_crc_sizescxx . . $ mz_zip_entry_write_crc_sizes(f71525ca20a31c0e).(void *stream, uint8_tcxx . . $ uint8_t# zip64, uint8_tcxx . . $ uint8_t# mask, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 524 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 525 | |
| 526 | if (mask) |
| 527 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, 0); |
| 528 | else |
| 529 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, file_info->crccxx . . $ mz_zip_file_s#crc.); /* crc */ |
| 530 | |
| 531 | /* For backwards-compatibility with older zip applications we set all sizes to UINT32_MAX |
| 532 | * when zip64 is needed, instead of only setting sizes larger than UINT32_MAX. */ |
| 533 | |
| 534 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 535 | if (zip64) /* compr size */ |
| 536 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 537 | else |
| 538 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size.); |
| 539 | } |
| 540 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 541 | if (mask) /* uncompr size */ |
| 542 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, 0); |
| 543 | else if (zip64) |
| 544 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 545 | else |
| 546 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 547 | } |
| 548 | return err; |
| 549 | } |
| 550 | |
| 551 | static int32_tcxx . . $ int32_t# mz_zip_entry_needs_zip64cxx . . $ mz_zip_entry_needs_zip64(503c767ff7c90557).(mz_zip_filecxx . . $ mz_zip_file# *file_info, uint8_tcxx . . $ uint8_t# local, uint8_tcxx . . $ uint8_t# *zip64) { |
| 552 | uint32_tcxx . . $ uint32_t# max_uncompressed_size = UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!; |
| 553 | uint8_tcxx . . $ uint8_t# needs_zip64 = 0; |
| 554 | |
| 555 | if (!zip64) |
| 556 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 557 | |
| 558 | *zip64 = 0; |
| 559 | |
| 560 | if (local) { |
| 561 | /* At local header we might not know yet whether compressed size will overflow unsigned |
| 562 | 32-bit integer which might happen for high entropy data so we give it some cushion */ |
| 563 | |
| 564 | max_uncompressed_size -= MZ_ZIP_UNCOMPR_SIZE64_CUSHIONcxx . . $ `mz_zip.c:76:9`!; |
| 565 | } |
| 566 | |
| 567 | needs_zip64 = (file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. >= max_uncompressed_size) || (file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 568 | |
| 569 | if (!local) { |
| 570 | /* Disk offset and number only used in central directory header */ |
| 571 | needs_zip64 |= (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) || (file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number. >= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!); |
| 572 | } |
| 573 | |
| 574 | if (file_info->zip64cxx . . $ mz_zip_file_s#zip64. == MZ_ZIP64_AUTOcxx . . $ `mz.h:97:9`!) { |
| 575 | /* If uncompressed size is unknown, assume zip64 for 64-bit data descriptors */ |
| 576 | if (local && file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. == 0) { |
| 577 | /* Don't use zip64 for local header directory entries */ |
| 578 | if (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(file_info->external_facxx . . $ mz_zip_file_s#external_fa., file_info->version_madebycxx . . $ mz_zip_file_s#version_madeby.) != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 579 | *zip64 = 1; |
| 580 | } |
| 581 | } |
| 582 | *zip64 |= needs_zip64; |
| 583 | } else if (file_info->zip64cxx . . $ mz_zip_file_s#zip64. == MZ_ZIP64_FORCEcxx . . $ `mz.h:98:9`!) { |
| 584 | *zip64 = 1; |
| 585 | } else if (file_info->zip64cxx . . $ mz_zip_file_s#zip64. == MZ_ZIP64_DISABLEcxx . . $ `mz.h:99:9`!) { |
| 586 | /* Zip64 extension is required to zip file */ |
| 587 | if (needs_zip64) |
| 588 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 589 | } |
| 590 | |
| 591 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 592 | } |
| 593 | |
| 594 | static int32_tcxx . . $ int32_t# mz_zip_entry_write_headercxx . . $ mz_zip_entry_write_header(c37012eda6503356).(void *stream, uint8_tcxx . . $ uint8_t# local, mz_zip_filecxx . . $ mz_zip_file# *file_info) { |
| 595 | uint64_tcxx . . $ uint64_t# ntfs_time = 0; |
| 596 | uint32_tcxx . . $ uint32_t# reserved = 0; |
| 597 | uint32_tcxx . . $ uint32_t# dos_date = 0; |
| 598 | uint16_tcxx . . $ uint16_t# extrafield_size = 0; |
| 599 | uint16_tcxx . . $ uint16_t# field_type = 0; |
| 600 | uint16_tcxx . . $ uint16_t# field_length = 0; |
| 601 | uint16_tcxx . . $ uint16_t# field_length_zip64 = 0; |
| 602 | uint16_tcxx . . $ uint16_t# field_length_ntfs = 0; |
| 603 | uint16_tcxx . . $ uint16_t# field_length_aes = 0; |
| 604 | uint16_tcxx . . $ uint16_t# field_length_unix1 = 0; |
| 605 | uint16_tcxx . . $ uint16_t# filename_size = 0; |
| 606 | uint16_tcxx . . $ uint16_t# filename_length = 0; |
| 607 | uint16_tcxx . . $ uint16_t# linkname_size = 0; |
| 608 | uint16_tcxx . . $ uint16_t# version_needed = 0; |
| 609 | int32_tcxx . . $ int32_t# comment_size = 0; |
| 610 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 611 | int32_tcxx . . $ int32_t# err_mem = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 612 | uint8_tcxx . . $ uint8_t# zip64 = 0; |
| 613 | uint8_tcxx . . $ uint8_t# skip_aes = 0; |
| 614 | uint8_tcxx . . $ uint8_t# mask = 0; |
| 615 | uint8_tcxx . . $ uint8_t# write_end_slash = 0; |
| 616 | const char *filename = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 617 | char masked_name[64]; |
| 618 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 619 | |
| 620 | if (!file_info) |
| 621 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 622 | |
| 623 | if ((local) && (file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_MASK_LOCAL_INFOcxx . . $ `mz.h:85:9`!)) |
| 624 | mask = 1; |
| 625 | |
| 626 | /* Determine if zip64 extra field is necessary */ |
| 627 | err = mz_zip_entry_needs_zip64cxx . . $ mz_zip_entry_needs_zip64(503c767ff7c90557).(file_info, local, &zip64); |
| 628 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 629 | return err; |
| 630 | |
| 631 | /* Start calculating extra field sizes */ |
| 632 | if (zip64) { |
| 633 | /* Both compressed and uncompressed sizes must be included (at least in local header) */ |
| 634 | field_length_zip64 = 8 + 8; |
| 635 | if ((!local) && (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) |
| 636 | field_length_zip64 += 8; |
| 637 | |
| 638 | extrafield_size += 4; |
| 639 | extrafield_size += field_length_zip64; |
| 640 | } |
| 641 | |
| 642 | /* Calculate extra field size and check for duplicates */ |
| 643 | if (file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. > 0) { |
| 644 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 645 | if (!file_extra_stream) |
| 646 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 647 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(file_extra_stream, (void *)file_info->extrafieldcxx . . $ mz_zip_file_s#extrafield., file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 648 | |
| 649 | do { |
| 650 | err_mem = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &field_type); |
| 651 | if (err_mem == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 652 | err_mem = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &field_length); |
| 653 | if (err_mem != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 654 | break; |
| 655 | |
| 656 | /* Prefer incoming aes extensions over ours */ |
| 657 | if (field_type == MZ_ZIP_EXTENSION_AEScxx . . $ `mz.h:90:9`!) |
| 658 | skip_aes = 1; |
| 659 | |
| 660 | /* Prefer our zip64, ntfs, unix1 extension over incoming */ |
| 661 | if (field_type != MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`! && field_type != MZ_ZIP_EXTENSION_NTFScxx . . $ `mz.h:89:9`! && |
| 662 | field_type != MZ_ZIP_EXTENSION_UNIX1cxx . . $ `mz.h:91:9`!) |
| 663 | extrafield_size += 4 + field_length; |
| 664 | |
| 665 | if (err_mem == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 666 | err_mem = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, field_length, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 667 | } while (err_mem == MZ_OKcxx . . $ `mz.h:21:9`!); |
| 668 | } |
| 669 | |
| 670 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 671 | if (!skip_aes) { |
| 672 | if ((file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) && (file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version.)) { |
| 673 | field_length_aes = 1 + 1 + 1 + 2 + 2; |
| 674 | extrafield_size += 4 + field_length_aes; |
| 675 | } |
| 676 | } |
| 677 | #else |
| 678 | MZ_UNUSED(field_length_aes); |
| 679 | MZ_UNUSED(skip_aes); |
| 680 | #endif |
| 681 | /* NTFS timestamps */ |
| 682 | if ((file_info->modified_datecxx . . $ mz_zip_file_s#modified_date. != 0) && (file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date. != 0) && (file_info->creation_datecxx . . $ mz_zip_file_s#creation_date. != 0) && |
| 683 | (!mask)) { |
| 684 | field_length_ntfs = 8 + 8 + 8 + 4 + 2 + 2; |
| 685 | extrafield_size += 4 + field_length_ntfs; |
| 686 | } |
| 687 | |
| 688 | /* Unix1 symbolic links */ |
| 689 | if (file_info->linknamecxx . . $ mz_zip_file_s#linkname. && *file_info->linknamecxx . . $ mz_zip_file_s#linkname. != 0) { |
| 690 | linkname_size = (uint16_tcxx . . $ uint16_t#)strlencxx . . $ strlen(751346f8406fd082).(file_info->linknamecxx . . $ mz_zip_file_s#linkname.); |
| 691 | field_length_unix1 = 12 + linkname_size; |
| 692 | extrafield_size += 4 + field_length_unix1; |
| 693 | } |
| 694 | |
| 695 | if (local) |
| 696 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, MZ_ZIP_MAGIC_LOCALHEADERcxx . . $ `mz_zip.c:59:9`!); |
| 697 | else { |
| 698 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, MZ_ZIP_MAGIC_CENTRALHEADERcxx . . $ `mz_zip.c:61:9`!); |
| 699 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 700 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->version_madebycxx . . $ mz_zip_file_s#version_madeby.); |
| 701 | } |
| 702 | |
| 703 | /* Calculate version needed to extract */ |
| 704 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 705 | version_needed = file_info->version_neededcxx . . $ mz_zip_file_s#version_needed.; |
| 706 | if (version_needed == 0) { |
| 707 | version_needed = 20; |
| 708 | if (zip64) |
| 709 | version_needed = 45; |
| 710 | #ifdef HAVE_BZIP2 |
| 711 | if (file_info->compression_method == MZ_COMPRESS_METHOD_BZIP2) |
| 712 | version_needed = 46; |
| 713 | #endif |
| 714 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 715 | if ((file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) && (file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version.)) |
| 716 | version_needed = 51; |
| 717 | #endif |
| 718 | #if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) |
| 719 | if ((file_info->compression_method == MZ_COMPRESS_METHOD_LZMA) || |
| 720 | (file_info->compression_method == MZ_COMPRESS_METHOD_XZ)) |
| 721 | version_needed = 63; |
| 722 | #endif |
| 723 | } |
| 724 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, version_needed); |
| 725 | } |
| 726 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 727 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->flagcxx . . $ mz_zip_file_s#flag.); |
| 728 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 729 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 730 | if ((file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) && (file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version.)) |
| 731 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, MZ_COMPRESS_METHOD_AEScxx . . $ `mz.h:69:9`!); |
| 732 | else |
| 733 | #endif |
| 734 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->compression_methodcxx . . $ mz_zip_file_s#compression_method.); |
| 735 | } |
| 736 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 737 | if (file_info->modified_datecxx . . $ mz_zip_file_s#modified_date. != 0 && !mask) |
| 738 | dos_date = mz_zip_time_t_to_dos_datecxx . . $ mz_zip_time_t_to_dos_date(bd267e0bd5a0c68b).(file_info->modified_datecxx . . $ mz_zip_file_s#modified_date.); |
| 739 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, dos_date); |
| 740 | } |
| 741 | |
| 742 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 743 | err = mz_zip_entry_write_crc_sizescxx . . $ mz_zip_entry_write_crc_sizes(f71525ca20a31c0e).(stream, zip64, mask, file_info); |
| 744 | |
| 745 | if (mask) { |
| 746 | snprintfcxx . . $ snprintf(ea502d73e74c754c).(masked_name, sizeof(masked_name), "%" PRIx32cxx . . $ `<external>/15933738808807975373/inttypes.h:120:10`! "_%" PRIx64cxx . . $ `<external>/15933738808807975373/inttypes.h:121:10`!, file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number., |
| 747 | file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset.); |
| 748 | filename = masked_name; |
| 749 | } else { |
| 750 | filename = file_info->filenamecxx . . $ mz_zip_file_s#filename.; |
| 751 | } |
| 752 | |
| 753 | filename_length = (uint16_tcxx . . $ uint16_t#)strlencxx . . $ strlen(751346f8406fd082).(filename); |
| 754 | filename_size += filename_length; |
| 755 | |
| 756 | if ((mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(file_info->external_facxx . . $ mz_zip_file_s#external_fa., file_info->version_madebycxx . . $ mz_zip_file_s#version_madeby.) == MZ_OKcxx . . $ `mz.h:21:9`!) && |
| 757 | ((filename[filename_length - 1] != '/') && (filename[filename_length - 1] != '\\'))) { |
| 758 | filename_size += 1; |
| 759 | write_end_slash = 1; |
| 760 | } |
| 761 | |
| 762 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 763 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, filename_size); |
| 764 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 765 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, extrafield_size); |
| 766 | |
| 767 | if (!local) { |
| 768 | if (file_info->commentcxx . . $ mz_zip_file_s#comment.) { |
| 769 | comment_size = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(file_info->commentcxx . . $ mz_zip_file_s#comment.); |
| 770 | if (comment_size > UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) |
| 771 | comment_size = UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!; |
| 772 | } |
| 773 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 774 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, (uint16_tcxx . . $ uint16_t#)comment_size); |
| 775 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 776 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, (uint16_tcxx . . $ uint16_t#)file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number.); |
| 777 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 778 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->internal_facxx . . $ mz_zip_file_s#internal_fa.); |
| 779 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 780 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, file_info->external_facxx . . $ mz_zip_file_s#external_fa.); |
| 781 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 782 | if (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) |
| 783 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 784 | else |
| 785 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset.); |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 790 | const char *next = filename; |
| 791 | int32_tcxx . . $ int32_t# left = filename_length; |
| 792 | #if defined(_WIN32) |
| 793 | const char *backslash = NULL; |
| 794 | |
| 795 | /* Ensure all slashes are written as forward slashes according to 4.4.17.1 */ |
| 796 | while ((err == MZ_OK) && (backslash = strchr(next, '\\'))) { |
| 797 | int32_t part_length = (int32_t)(backslash - next); |
| 798 | |
| 799 | if (mz_stream_write(stream, next, part_length) != part_length || mz_stream_write(stream, "/", 1) != 1) |
| 800 | err = MZ_WRITE_ERROR; |
| 801 | |
| 802 | left -= part_length + 1; |
| 803 | next = backslash + 1; |
| 804 | } |
| 805 | #endif |
| 806 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && left > 0) { |
| 807 | if (mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(stream, next, left) != left) |
| 808 | err = MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 809 | } |
| 810 | |
| 811 | /* Ensure that directories have a slash appended to them for compatibility */ |
| 812 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && write_end_slash) |
| 813 | err = mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(stream, '/'); |
| 814 | } |
| 815 | |
| 816 | /* Write ZIP64 extra field first so we can update sizes later if data descriptor not used */ |
| 817 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip64)) { |
| 818 | err = mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(stream, MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`!, field_length_zip64); |
| 819 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 820 | if (mask) |
| 821 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, 0); |
| 822 | else |
| 823 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, file_info->uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 824 | } |
| 825 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 826 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, file_info->compressed_sizecxx . . $ mz_zip_file_s#compressed_size.); |
| 827 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (!local) && (file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) |
| 828 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, file_info->disk_offsetcxx . . $ mz_zip_file_s#disk_offset.); |
| 829 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (!local) && (file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number. >= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!)) |
| 830 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, file_info->disk_numbercxx . . $ mz_zip_file_s#disk_number.); |
| 831 | } |
| 832 | /* Write NTFS extra field */ |
| 833 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (field_length_ntfs > 0)) { |
| 834 | err = mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(stream, MZ_ZIP_EXTENSION_NTFScxx . . $ `mz.h:89:9`!, field_length_ntfs); |
| 835 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 836 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, reserved); |
| 837 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 838 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, 0x01); |
| 839 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 840 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, field_length_ntfs - 8); |
| 841 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 842 | mz_zip_unix_to_ntfs_timecxx . . $ mz_zip_unix_to_ntfs_time(a0529548657e71e7).(file_info->modified_datecxx . . $ mz_zip_file_s#modified_date., &ntfs_time); |
| 843 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(stream, ntfs_time); |
| 844 | } |
| 845 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 846 | mz_zip_unix_to_ntfs_timecxx . . $ mz_zip_unix_to_ntfs_time(a0529548657e71e7).(file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date., &ntfs_time); |
| 847 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(stream, ntfs_time); |
| 848 | } |
| 849 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 850 | mz_zip_unix_to_ntfs_timecxx . . $ mz_zip_unix_to_ntfs_time(a0529548657e71e7).(file_info->creation_datecxx . . $ mz_zip_file_s#creation_date., &ntfs_time); |
| 851 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(stream, ntfs_time); |
| 852 | } |
| 853 | } |
| 854 | /* Write UNIX extra block extra field */ |
| 855 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (field_length_unix1 > 0)) { |
| 856 | err = mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(stream, MZ_ZIP_EXTENSION_UNIX1cxx . . $ `mz.h:91:9`!, field_length_unix1); |
| 857 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 858 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)file_info->accessed_datecxx . . $ mz_zip_file_s#accessed_date.); |
| 859 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 860 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)file_info->modified_datecxx . . $ mz_zip_file_s#modified_date.); |
| 861 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) /* User id */ |
| 862 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, 0); |
| 863 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) /* Group id */ |
| 864 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, 0); |
| 865 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && linkname_size > 0) { |
| 866 | if (mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(stream, file_info->linknamecxx . . $ mz_zip_file_s#linkname., linkname_size) != linkname_size) |
| 867 | err = MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 868 | } |
| 869 | } |
| 870 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 871 | /* Write AES extra field */ |
| 872 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (!skip_aes) && (file_info->flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) && (file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version.)) { |
| 873 | err = mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(stream, MZ_ZIP_EXTENSION_AEScxx . . $ `mz.h:90:9`!, field_length_aes); |
| 874 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 875 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->aes_versioncxx . . $ mz_zip_file_s#aes_version.); |
| 876 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 877 | err = mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(stream, 'A'); |
| 878 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 879 | err = mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(stream, 'E'); |
| 880 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 881 | err = mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(stream, file_info->aes_strengthcxx . . $ mz_zip_file_s#aes_strength.); |
| 882 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 883 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, file_info->compression_methodcxx . . $ mz_zip_file_s#compression_method.); |
| 884 | } |
| 885 | #endif |
| 886 | |
| 887 | if (file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. > 0) { |
| 888 | err_mem = mz_stream_mem_seekcxx . . $ mz_stream_mem_seek(8bc0ff128761c75d).(file_extra_stream, 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 889 | while (err == MZ_OKcxx . . $ `mz.h:21:9`! && err_mem == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 890 | err_mem = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &field_type); |
| 891 | if (err_mem == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 892 | err_mem = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(file_extra_stream, &field_length); |
| 893 | if (err_mem != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 894 | break; |
| 895 | |
| 896 | /* Prefer our zip 64, ntfs, unix1 extensions over incoming */ |
| 897 | if (field_type == MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`! || field_type == MZ_ZIP_EXTENSION_NTFScxx . . $ `mz.h:89:9`! || |
| 898 | field_type == MZ_ZIP_EXTENSION_UNIX1cxx . . $ `mz.h:91:9`!) { |
| 899 | err_mem = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(file_extra_stream, field_length, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 900 | continue; |
| 901 | } |
| 902 | |
| 903 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, field_type); |
| 904 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 905 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, field_length); |
| 906 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 907 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(stream, file_extra_stream, field_length); |
| 908 | } |
| 909 | |
| 910 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 911 | } |
| 912 | |
| 913 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && !local && file_info->commentcxx . . $ mz_zip_file_s#comment.) { |
| 914 | if (mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(stream, file_info->commentcxx . . $ mz_zip_file_s#comment., file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size.) != file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size.) |
| 915 | err = MZ_WRITE_ERRORcxx . . $ `mz.h:45:9`!; |
| 916 | } |
| 917 | |
| 918 | return err; |
| 919 | } |
| 920 | |
| 921 | static int32_tcxx . . $ int32_t# mz_zip_entry_write_descriptorcxx . . $ mz_zip_entry_write_descriptor(d9f1f10a766e3bb4).(void *stream, uint8_tcxx . . $ uint8_t# zip64, uint32_tcxx . . $ uint32_t# crc32, int64_tcxx . . $ int64_t# compressed_size, |
| 922 | int64_tcxx . . $ int64_t# uncompressed_size) { |
| 923 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 924 | |
| 925 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, MZ_ZIP_MAGIC_DATADESCRIPTORcxx . . $ `mz_zip.c:67:9`!); |
| 926 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 927 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, crc32); |
| 928 | |
| 929 | /* Store data descriptor as 8 bytes if zip 64 extension enabled */ |
| 930 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 931 | /* Zip 64 extension is enabled when uncompressed size is > UINT32_MAX */ |
| 932 | if (!zip64) |
| 933 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)compressed_size); |
| 934 | else |
| 935 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, compressed_size); |
| 936 | } |
| 937 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 938 | if (!zip64) |
| 939 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(stream, (uint32_tcxx . . $ uint32_t#)uncompressed_size); |
| 940 | else |
| 941 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(stream, uncompressed_size); |
| 942 | } |
| 943 | |
| 944 | return err; |
| 945 | } |
| 946 | |
| 947 | static int32_tcxx . . $ int32_t# mz_zip_read_cdcxx . . $ mz_zip_read_cd(dedf1e9b1c614a07).(void *handle) { |
| 948 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 949 | uint64_tcxx . . $ uint64_t# number_entry_cd64 = 0; |
| 950 | uint64_tcxx . . $ uint64_t# number_entry_cd = 0; |
| 951 | int64_tcxx . . $ int64_t# eocd_pos = 0; |
| 952 | int64_tcxx . . $ int64_t# eocd_pos64 = 0; |
| 953 | int64_tcxx . . $ int64_t# value64i = 0; |
| 954 | uint16_tcxx . . $ uint16_t# value16 = 0; |
| 955 | uint32_tcxx . . $ uint32_t# value32 = 0; |
| 956 | uint64_tcxx . . $ uint64_t# value64 = 0; |
| 957 | uint16_tcxx . . $ uint16_t# comment_size = 0; |
| 958 | int32_tcxx . . $ int32_t# comment_read = 0; |
| 959 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 960 | |
| 961 | if (!zip) |
| 962 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 963 | |
| 964 | /* Read and cache central directory records */ |
| 965 | err = mz_zip_search_eocdcxx . . $ mz_zip_search_eocd(3c3380c49b0234ac).(zip->streamcxx . . $ mz_zip_s#stream., &eocd_pos); |
| 966 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 967 | /* The signature, already checked */ |
| 968 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &value32); |
| 969 | /* Number of this disk */ |
| 970 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 971 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &value16); |
| 972 | /* Number of the disk with the start of the central directory */ |
| 973 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 974 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &value16); |
| 975 | zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. = value16; |
| 976 | /* Total number of entries in the central dir on this disk */ |
| 977 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 978 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &value16); |
| 979 | zip->number_entrycxx . . $ mz_zip_s#number_entry. = value16; |
| 980 | /* Total number of entries in the central dir */ |
| 981 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 982 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &value16); |
| 983 | number_entry_cd = value16; |
| 984 | /* When recover is enabled, we can ignore incorrect number of entries */ |
| 985 | if (number_entry_cd != zip->number_entrycxx . . $ mz_zip_s#number_entry. && !zip->recovercxx . . $ mz_zip_s#recover.) |
| 986 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 987 | /* Size of the central directory */ |
| 988 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 989 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &value32); |
| 990 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 991 | zip->cd_sizecxx . . $ mz_zip_s#cd_size. = value32; |
| 992 | /* Offset of start of central directory with respect to the starting disk number */ |
| 993 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 994 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &value32); |
| 995 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 996 | zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. = value32; |
| 997 | /* Zip file global comment length */ |
| 998 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 999 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &comment_size); |
| 1000 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (comment_size > 0)) { |
| 1001 | zip->commentcxx . . $ mz_zip_s#comment. = (char *)malloccxx . . $ malloc(bfcfa4d6b7f7ef64).(comment_size + 1); |
| 1002 | if (zip->commentcxx . . $ mz_zip_s#comment.) { |
| 1003 | comment_read = mz_stream_readcxx . . $ mz_stream_read(8bc41909eac9e5d8).(zip->streamcxx . . $ mz_zip_s#stream., zip->commentcxx . . $ mz_zip_s#comment., comment_size); |
| 1004 | /* Don't fail if incorrect comment length read, not critical */ |
| 1005 | if (comment_read < 0) |
| 1006 | comment_read = 0; |
| 1007 | zip->commentcxx . . $ mz_zip_s#comment.[comment_read] = 0; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && ((number_entry_cd == UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) || (zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. == UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!))) { |
| 1012 | /* Format should be Zip64, as the central directory or file size is too large */ |
| 1013 | if (mz_zip_search_zip64_eocdcxx . . $ mz_zip_search_zip64_eocd(98b7c25805f7791).(zip->streamcxx . . $ mz_zip_s#stream., eocd_pos, &eocd_pos64) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1014 | eocd_pos = eocd_pos64; |
| 1015 | |
| 1016 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., eocd_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1017 | /* The signature, already checked */ |
| 1018 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1019 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &value32); |
| 1020 | /* Size of zip64 end of central directory record */ |
| 1021 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1022 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(zip->streamcxx . . $ mz_zip_s#stream., &value64); |
| 1023 | /* Version made by */ |
| 1024 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1025 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &zip->version_madebycxx . . $ mz_zip_s#version_madeby.); |
| 1026 | /* Version needed to extract */ |
| 1027 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1028 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(zip->streamcxx . . $ mz_zip_s#stream., &value16); |
| 1029 | /* Number of this disk */ |
| 1030 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1031 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &value32); |
| 1032 | /* Number of the disk with the start of the central directory */ |
| 1033 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1034 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1035 | /* Total number of entries in the central directory on this disk */ |
| 1036 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1037 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(zip->streamcxx . . $ mz_zip_s#stream., &zip->number_entrycxx . . $ mz_zip_s#number_entry.); |
| 1038 | /* Total number of entries in the central directory */ |
| 1039 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1040 | err = mz_stream_read_uint64cxx . . $ mz_stream_read_uint64(17c9a57913c314f0).(zip->streamcxx . . $ mz_zip_s#stream., &number_entry_cd64); |
| 1041 | if (zip->number_entrycxx . . $ mz_zip_s#number_entry. != number_entry_cd64) |
| 1042 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1043 | /* Size of the central directory */ |
| 1044 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1045 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(zip->streamcxx . . $ mz_zip_s#stream., &zip->cd_sizecxx . . $ mz_zip_s#cd_size.); |
| 1046 | if (zip->cd_sizecxx . . $ mz_zip_s#cd_size. < 0) |
| 1047 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1048 | } |
| 1049 | /* Offset of start of central directory with respect to the starting disk number */ |
| 1050 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1051 | err = mz_stream_read_int64cxx . . $ mz_stream_read_int64(3c3380c49b0234ac).(zip->streamcxx . . $ mz_zip_s#stream., &zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.); |
| 1052 | if (zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. < 0) |
| 1053 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1054 | } |
| 1055 | } else if ((zip->number_entrycxx . . $ mz_zip_s#number_entry. == UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) || (number_entry_cd != zip->number_entrycxx . . $ mz_zip_s#number_entry.) || |
| 1056 | (zip->cd_sizecxx . . $ mz_zip_s#cd_size. == UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) || (zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. == UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!)) { |
| 1057 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1058 | } |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1063 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Read cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", |
| 1064 | zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); |
| 1065 | |
| 1066 | /* Verify central directory signature exists at offset */ |
| 1067 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_offsetcxx . . $ mz_zip_s#cd_offset., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1068 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1069 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &zip->cd_signaturecxx . . $ mz_zip_s#cd_signature.); |
| 1070 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip->cd_signaturecxx . . $ mz_zip_s#cd_signature. != MZ_ZIP_MAGIC_CENTRALHEADERcxx . . $ `mz_zip.c:61:9`!)) { |
| 1071 | /* If cd exists in large file and no zip-64 support, error for recover */ |
| 1072 | if (eocd_pos > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`! && eocd_pos64 == 0) |
| 1073 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1074 | /* If cd not found attempt to seek backward to find it */ |
| 1075 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1076 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., eocd_pos - zip->cd_sizecxx . . $ mz_zip_s#cd_size., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1077 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1078 | err = mz_stream_read_uint32cxx . . $ mz_stream_read_uint32(3569d74970a1d1f9).(zip->streamcxx . . $ mz_zip_s#stream., &zip->cd_signaturecxx . . $ mz_zip_s#cd_signature.); |
| 1079 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip->cd_signaturecxx . . $ mz_zip_s#cd_signature. == MZ_ZIP_MAGIC_CENTRALHEADERcxx . . $ `mz_zip.c:61:9`!)) { |
| 1080 | /* If found compensate for incorrect locations */ |
| 1081 | value64i = zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.; |
| 1082 | zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. = eocd_pos - zip->cd_sizecxx . . $ mz_zip_s#cd_size.; |
| 1083 | /* Assume disk has prepended data */ |
| 1084 | zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift. = zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. - value64i; |
| 1085 | } |
| 1086 | } |
| 1087 | } |
| 1088 | |
| 1089 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1090 | if (eocd_pos < zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.) { |
| 1091 | /* End of central dir should always come after central dir */ |
| 1092 | err = MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1093 | } else if ((uint64_tcxx . . $ uint64_t#)eocd_pos < (uint64_tcxx . . $ uint64_t#)zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. + zip->cd_sizecxx . . $ mz_zip_s#cd_size.) { |
| 1094 | /* Truncate size of cd if incorrect size or offset provided */ |
| 1095 | zip->cd_sizecxx . . $ mz_zip_s#cd_size. = eocd_pos - zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.; |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | return err; |
| 1100 | } |
| 1101 | |
| 1102 | static int32_tcxx . . $ int32_t# mz_zip_write_cdcxx . . $ mz_zip_write_cd(dedf1e9b1c614a07).(void *handle) { |
| 1103 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1104 | int64_tcxx . . $ int64_t# zip64_eocd_pos_inzip = 0; |
| 1105 | int64_tcxx . . $ int64_t# disk_number = 0; |
| 1106 | int64_tcxx . . $ int64_t# disk_size = 0; |
| 1107 | int32_tcxx . . $ int32_t# comment_size = 0; |
| 1108 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1109 | |
| 1110 | if (!zip) |
| 1111 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1112 | |
| 1113 | if (mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, &disk_number) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1114 | zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. = (uint32_tcxx . . $ uint32_t#)disk_number; |
| 1115 | if (mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_SIZEcxx . . $ `mz_strm.h:26:9`!, &disk_size) == MZ_OKcxx . . $ `mz.h:21:9`! && disk_size > 0) |
| 1116 | zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. += 1; |
| 1117 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, -1); |
| 1118 | if ((zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. > 0) && (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!)) { |
| 1119 | /* Overwrite existing central directory if using split disks */ |
| 1120 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1121 | } |
| 1122 | |
| 1123 | zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 1124 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 1125 | zip->cd_sizecxx . . $ mz_zip_s#cd_size. = (uint32_tcxx . . $ uint32_t#)mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.); |
| 1126 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1127 | |
| 1128 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., (int32_tcxx . . $ int32_t#)zip->cd_sizecxx . . $ mz_zip_s#cd_size.); |
| 1129 | |
| 1130 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Write cd (disk %" PRId32 " entries %" PRId64 " offset %" PRId64 " size %" PRId64 ")\n", |
| 1131 | zip->disk_number_with_cd, zip->number_entry, zip->cd_offset, zip->cd_size); |
| 1132 | |
| 1133 | if (zip->cd_sizecxx . . $ mz_zip_s#cd_size. == 0 && zip->number_entrycxx . . $ mz_zip_s#number_entry. > 0) { |
| 1134 | /* Zip does not contain central directory, open with recovery option */ |
| 1135 | return MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 1136 | } |
| 1137 | |
| 1138 | /* Write the ZIP64 central directory header */ |
| 1139 | if (zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`! || zip->number_entrycxx . . $ mz_zip_s#number_entry. >= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) { |
| 1140 | zip64_eocd_pos_inzip = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 1141 | |
| 1142 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., MZ_ZIP_MAGIC_ENDHEADER64cxx . . $ `mz_zip.c:65:9`!); |
| 1143 | |
| 1144 | /* Size of this 'zip64 end of central directory' */ |
| 1145 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1146 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(zip->streamcxx . . $ mz_zip_s#stream., (uint64_tcxx . . $ uint64_t#)44); |
| 1147 | /* Version made by */ |
| 1148 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1149 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., zip->version_madebycxx . . $ mz_zip_s#version_madeby.); |
| 1150 | /* Version needed */ |
| 1151 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1152 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)45); |
| 1153 | /* Number of this disk */ |
| 1154 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1155 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1156 | /* Number of the disk with the start of the central directory */ |
| 1157 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1158 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1159 | /* Total number of entries in the central dir on this disk */ |
| 1160 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1161 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(zip->streamcxx . . $ mz_zip_s#stream., zip->number_entrycxx . . $ mz_zip_s#number_entry.); |
| 1162 | /* Total number of entries in the central dir */ |
| 1163 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1164 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(zip->streamcxx . . $ mz_zip_s#stream., zip->number_entrycxx . . $ mz_zip_s#number_entry.); |
| 1165 | /* Size of the central directory */ |
| 1166 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1167 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_sizecxx . . $ mz_zip_s#cd_size.); |
| 1168 | /* Offset of start of central directory with respect to the starting disk number */ |
| 1169 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1170 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.); |
| 1171 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1172 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., MZ_ZIP_MAGIC_ENDLOCHEADER64cxx . . $ `mz_zip.c:66:9`!); |
| 1173 | |
| 1174 | /* Number of the disk with the start of the central directory */ |
| 1175 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1176 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1177 | /* Relative offset to the end of zip64 central directory */ |
| 1178 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1179 | err = mz_stream_write_int64cxx . . $ mz_stream_write_int64(6b20ed9d0f5b4b14).(zip->streamcxx . . $ mz_zip_s#stream., zip64_eocd_pos_inzip); |
| 1180 | /* Number of the disk with the start of the central directory */ |
| 1181 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1182 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. + 1); |
| 1183 | } |
| 1184 | |
| 1185 | /* Write the central directory header */ |
| 1186 | |
| 1187 | /* Signature */ |
| 1188 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1189 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., MZ_ZIP_MAGIC_ENDHEADERcxx . . $ `mz_zip.c:63:9`!); |
| 1190 | /* Number of this disk */ |
| 1191 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1192 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1193 | /* Number of the disk with the start of the central directory */ |
| 1194 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1195 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.); |
| 1196 | /* Total number of entries in the central dir on this disk */ |
| 1197 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1198 | if (zip->number_entrycxx . . $ mz_zip_s#number_entry. >= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) |
| 1199 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!); |
| 1200 | else |
| 1201 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)zip->number_entrycxx . . $ mz_zip_s#number_entry.); |
| 1202 | } |
| 1203 | /* Total number of entries in the central dir */ |
| 1204 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1205 | if (zip->number_entrycxx . . $ mz_zip_s#number_entry. >= UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) |
| 1206 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!); |
| 1207 | else |
| 1208 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)zip->number_entrycxx . . $ mz_zip_s#number_entry.); |
| 1209 | } |
| 1210 | /* Size of the central directory */ |
| 1211 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1212 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., (uint32_tcxx . . $ uint32_t#)zip->cd_sizecxx . . $ mz_zip_s#cd_size.); |
| 1213 | /* Offset of start of central directory with respect to the starting disk number */ |
| 1214 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1215 | if (zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. >= UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) |
| 1216 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!); |
| 1217 | else |
| 1218 | err = mz_stream_write_uint32cxx . . $ mz_stream_write_uint32(6fe7d876f9648735).(zip->streamcxx . . $ mz_zip_s#stream., (uint32_tcxx . . $ uint32_t#)zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.); |
| 1219 | } |
| 1220 | |
| 1221 | /* Write global comment */ |
| 1222 | if (zip->commentcxx . . $ mz_zip_s#comment.) { |
| 1223 | comment_size = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(zip->commentcxx . . $ mz_zip_s#comment.); |
| 1224 | if (comment_size > UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) |
| 1225 | comment_size = UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!; |
| 1226 | } |
| 1227 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1228 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(zip->streamcxx . . $ mz_zip_s#stream., (uint16_tcxx . . $ uint16_t#)comment_size); |
| 1229 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1230 | if (mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->streamcxx . . $ mz_zip_s#stream., zip->commentcxx . . $ mz_zip_s#comment., comment_size) != comment_size) |
| 1231 | err = MZ_READ_ERRORcxx . . $ `mz.h:44:9`!; |
| 1232 | } |
| 1233 | return err; |
| 1234 | } |
| 1235 | |
| 1236 | static int32_tcxx . . $ int32_t# mz_zip_recover_cdcxx . . $ mz_zip_recover_cd(dedf1e9b1c614a07).(void *handle) { |
| 1237 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1238 | mz_zip_filecxx . . $ mz_zip_file# local_file_info; |
| 1239 | void *local_file_info_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1240 | void *cd_mem_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1241 | uint64_tcxx . . $ uint64_t# number_entry = 0; |
| 1242 | int64_tcxx . . $ int64_t# descriptor_pos = 0; |
| 1243 | int64_tcxx . . $ int64_t# next_header_pos = 0; |
| 1244 | int64_tcxx . . $ int64_t# disk_offset = 0; |
| 1245 | int64_tcxx . . $ int64_t# disk_number = 0; |
| 1246 | int64_tcxx . . $ int64_t# compressed_pos = 0; |
| 1247 | int64_tcxx . . $ int64_t# compressed_end_pos = 0; |
| 1248 | int64_tcxx . . $ int64_t# compressed_size = 0; |
| 1249 | int64_tcxx . . $ int64_t# uncompressed_size = 0; |
| 1250 | uint8_tcxx . . $ uint8_t# descriptor_magic[4] = MZ_ZIP_MAGIC_DATADESCRIPTORU8cxx . . $ `mz_zip.c:68:9`!; |
| 1251 | uint8_tcxx . . $ uint8_t# local_header_magic[4] = MZ_ZIP_MAGIC_LOCALHEADERU8cxx . . $ `mz_zip.c:60:9`!; |
| 1252 | uint8_tcxx . . $ uint8_t# central_header_magic[4] = MZ_ZIP_MAGIC_CENTRALHEADERU8cxx . . $ `mz_zip.c:62:9`!; |
| 1253 | uint32_tcxx . . $ uint32_t# crc32 = 0; |
| 1254 | int32_tcxx . . $ int32_t# disk_number_with_cd = 0; |
| 1255 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1256 | uint8_tcxx . . $ uint8_t# zip64 = 0; |
| 1257 | uint8_tcxx . . $ uint8_t# eof = 0; |
| 1258 | |
| 1259 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Recover - Start\n"); |
| 1260 | |
| 1261 | mz_zip_get_cd_mem_streamcxx . . $ mz_zip_get_cd_mem_stream(1843ed636859e0d0).(handle, &cd_mem_stream); |
| 1262 | |
| 1263 | /* Determine if we are on a split disk or not */ |
| 1264 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, 0); |
| 1265 | if (mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.) < 0) { |
| 1266 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, -1); |
| 1267 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1268 | } else |
| 1269 | disk_number_with_cd = 1; |
| 1270 | |
| 1271 | local_file_info_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1272 | if (!local_file_info_stream) |
| 1273 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1274 | |
| 1275 | if (mz_stream_is_opencxx . . $ mz_stream_is_open(dedf1e9b1c614a07).(cd_mem_stream) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1276 | err = 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`!); |
| 1277 | |
| 1278 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(local_file_info_stream, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1279 | |
| 1280 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1281 | err = mz_stream_findcxx . . $ mz_stream_find(8aa461340cfae934).(zip->streamcxx . . $ mz_zip_s#stream., (const void *)local_header_magic, sizeof(local_header_magic), INT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:113:10`!, |
| 1282 | &next_header_pos); |
| 1283 | } |
| 1284 | |
| 1285 | while (err == MZ_OKcxx . . $ `mz.h:21:9`! && !eof) { |
| 1286 | /* Get current offset and disk number for central dir record */ |
| 1287 | disk_offset = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 1288 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, &disk_number); |
| 1289 | |
| 1290 | /* Read local headers */ |
| 1291 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&local_file_info, 0, sizeof(local_file_info)); |
| 1292 | err = mz_zip_entry_read_headercxx . . $ mz_zip_entry_read_header(22e9f4de044eb2c0).(zip->streamcxx . . $ mz_zip_s#stream., 1, &local_file_info, local_file_info_stream); |
| 1293 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1294 | break; |
| 1295 | |
| 1296 | local_file_info.disk_offsetcxx . . $ mz_zip_file_s#disk_offset. = disk_offset; |
| 1297 | if (disk_number < 0) |
| 1298 | disk_number = 0; |
| 1299 | local_file_info.disk_numbercxx . . $ mz_zip_file_s#disk_number. = (uint32_tcxx . . $ uint32_t#)disk_number; |
| 1300 | |
| 1301 | compressed_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 1302 | |
| 1303 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size. > 0)) { |
| 1304 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size., MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 1305 | } |
| 1306 | |
| 1307 | for (;;) { |
| 1308 | /* Search for the next local header */ |
| 1309 | err = mz_stream_findcxx . . $ mz_stream_find(8aa461340cfae934).(zip->streamcxx . . $ mz_zip_s#stream., (const void *)local_header_magic, sizeof(local_header_magic), INT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:113:10`!, |
| 1310 | &next_header_pos); |
| 1311 | |
| 1312 | if (err == MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!) { |
| 1313 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., compressed_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1314 | |
| 1315 | /* Search for central dir if no local header found */ |
| 1316 | err = mz_stream_findcxx . . $ mz_stream_find(8aa461340cfae934).(zip->streamcxx . . $ mz_zip_s#stream., (const void *)central_header_magic, sizeof(central_header_magic), |
| 1317 | INT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:113:10`!, &next_header_pos); |
| 1318 | |
| 1319 | if (err == MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!) { |
| 1320 | /* Get end of stream if no central header found */ |
| 1321 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 1322 | next_header_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 1323 | } |
| 1324 | |
| 1325 | eof = 1; |
| 1326 | } |
| 1327 | |
| 1328 | if (local_file_info.flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`! || local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size. == 0) { |
| 1329 | /* Search backwards for the descriptor, seeking too far back will be incorrect if compressed size is |
| 1330 | * small */ |
| 1331 | err = mz_stream_find_reversecxx . . $ mz_stream_find_reverse(8aa461340cfae934).(zip->streamcxx . . $ mz_zip_s#stream., (const void *)descriptor_magic, sizeof(descriptor_magic), |
| 1332 | MZ_ZIP_SIZE_MAX_DATA_DESCRIPTORcxx . . $ `mz_zip.c:73:9`!, &descriptor_pos); |
| 1333 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1334 | if (mz_zip_extrafield_containscxx . . $ mz_zip_extrafield_contains(b9c376550f650e).(local_file_info.extrafieldcxx . . $ mz_zip_file_s#extrafield., local_file_info.extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size., |
| 1335 | MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1336 | zip64 = 1; |
| 1337 | |
| 1338 | err = |
| 1339 | mz_zip_entry_read_descriptorcxx . . $ mz_zip_entry_read_descriptor(f7c6753e6a4e27a9).(zip->streamcxx . . $ mz_zip_s#stream., zip64, &crc32, &compressed_size, &uncompressed_size); |
| 1340 | |
| 1341 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1342 | if (local_file_info.crccxx . . $ mz_zip_file_s#crc. == 0) |
| 1343 | local_file_info.crccxx . . $ mz_zip_file_s#crc. = crc32; |
| 1344 | if (local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size. == 0) |
| 1345 | local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size. = compressed_size; |
| 1346 | if (local_file_info.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. == 0) |
| 1347 | local_file_info.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = uncompressed_size; |
| 1348 | } |
| 1349 | |
| 1350 | compressed_end_pos = descriptor_pos; |
| 1351 | } else if (eof) { |
| 1352 | compressed_end_pos = next_header_pos; |
| 1353 | } else if (local_file_info.flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!) { |
| 1354 | /* Wrong local file entry found, keep searching */ |
| 1355 | next_header_pos += 1; |
| 1356 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., next_header_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1357 | continue; |
| 1358 | } |
| 1359 | } else { |
| 1360 | compressed_end_pos = next_header_pos; |
| 1361 | } |
| 1362 | |
| 1363 | break; |
| 1364 | } |
| 1365 | |
| 1366 | compressed_size = compressed_end_pos - compressed_pos; |
| 1367 | |
| 1368 | if (compressed_size > UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) { |
| 1369 | /* Update sizes if 4GB file is written with no ZIP64 support */ |
| 1370 | if (local_file_info.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. < UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`!) { |
| 1371 | local_file_info.compressed_sizecxx . . $ mz_zip_file_s#compressed_size. = compressed_size; |
| 1372 | local_file_info.uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = 0; |
| 1373 | } |
| 1374 | } |
| 1375 | |
| 1376 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Recover - Entry %s (csize %" PRId64 " usize %" PRId64 " flags 0x%" PRIx16 ")\n", |
| 1377 | local_file_info.filename, local_file_info.compressed_size, local_file_info.uncompressed_size, |
| 1378 | local_file_info.flag); |
| 1379 | |
| 1380 | /* Rewrite central dir with local headers and offsets */ |
| 1381 | err = mz_zip_entry_write_headercxx . . $ mz_zip_entry_write_header(c37012eda6503356).(cd_mem_stream, 0, &local_file_info); |
| 1382 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1383 | number_entry += 1; |
| 1384 | |
| 1385 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., next_header_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1386 | } |
| 1387 | |
| 1388 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&local_file_info_stream); |
| 1389 | |
| 1390 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Recover - Complete (cddisk %" PRId32 " entries %" PRId64 ")\n", disk_number_with_cd, |
| 1391 | number_entry); |
| 1392 | |
| 1393 | if (number_entry == 0) |
| 1394 | return err; |
| 1395 | |
| 1396 | /* Set new upper seek boundary for central dir mem stream */ |
| 1397 | disk_offset = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(cd_mem_stream); |
| 1398 | mz_stream_mem_set_buffer_limitcxx . . $ mz_stream_mem_set_buffer_limit(d0320739773070f2).(cd_mem_stream, (int32_tcxx . . $ int32_t#)disk_offset); |
| 1399 | |
| 1400 | /* Set new central directory info */ |
| 1401 | mz_zip_set_cd_streamcxx . . $ mz_zip_set_cd_stream(ebe495d140c0cd6c).(handle, 0, cd_mem_stream); |
| 1402 | mz_zip_set_number_entrycxx . . $ mz_zip_set_number_entry(c0a5f96701d3f89).(handle, number_entry); |
| 1403 | mz_zip_set_disk_number_with_cdcxx . . $ mz_zip_set_disk_number_with_cd(6fe7d876f9648735).(handle, disk_number_with_cd); |
| 1404 | |
| 1405 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1406 | } |
| 1407 | |
| 1408 | void *mz_zip_createcxx . . $ mz_zip_create(50c7df7de5344ebb).(void) { |
| 1409 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(1, sizeof(mz_zipcxx . . $ mz_zip#)); |
| 1410 | if (zip) |
| 1411 | zip->data_descriptorcxx . . $ mz_zip_s#data_descriptor. = 1; |
| 1412 | return zip; |
| 1413 | } |
| 1414 | |
| 1415 | void mz_zip_deletecxx . . $ mz_zip_delete(539e082cf00e1f43).(void **handle) { |
| 1416 | mz_zipcxx . . $ mz_zip# *zip = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1417 | if (!handle) |
| 1418 | return; |
| 1419 | zip = (mz_zipcxx . . $ mz_zip# *)*handle; |
| 1420 | freecxx . . $ free(5d22bdacc48458e8).(zip); |
| 1421 | *handle = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1422 | } |
| 1423 | |
| 1424 | int32_tcxx . . $ int32_t# mz_zip_opencxx . . $ mz_zip_open(8bc41909eac9e5d8).(void *handle, void *stream, int32_tcxx . . $ int32_t# mode) { |
| 1425 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1426 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1427 | |
| 1428 | if (!zip) |
| 1429 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1430 | |
| 1431 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Open\n"); |
| 1432 | |
| 1433 | zip->streamcxx . . $ mz_zip_s#stream. = stream; |
| 1434 | zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1435 | if (!zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.) |
| 1436 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1437 | |
| 1438 | if (mode & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) { |
| 1439 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1440 | zip->cd_streamcxx . . $ mz_zip_s#cd_stream. = zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.; |
| 1441 | } else { |
| 1442 | zip->cd_streamcxx . . $ mz_zip_s#cd_stream. = stream; |
| 1443 | } |
| 1444 | |
| 1445 | if ((mode & MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!) || (mode & MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!)) { |
| 1446 | if ((mode & MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!) == 0) { |
| 1447 | err = mz_zip_read_cdcxx . . $ mz_zip_read_cd(dedf1e9b1c614a07).(zip); |
| 1448 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1449 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Error detected reading cd (%" PRId32 ")\n", err); |
| 1450 | if (zip->recovercxx . . $ mz_zip_s#recover. && mz_zip_recover_cdcxx . . $ mz_zip_recover_cd(dedf1e9b1c614a07).(zip) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1451 | err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1452 | } |
| 1453 | } |
| 1454 | |
| 1455 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (mode & MZ_OPEN_MODE_APPENDcxx . . $ `mz.h:53:9`!)) { |
| 1456 | if (zip->cd_sizecxx . . $ mz_zip_s#cd_size. > 0) { |
| 1457 | /* Store central directory in memory */ |
| 1458 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_offsetcxx . . $ mz_zip_s#cd_offset., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1459 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1460 | err = mz_stream_copycxx . . $ mz_stream_copy(8bc41909eac9e5d8).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., zip->streamcxx . . $ mz_zip_s#stream., (int32_tcxx . . $ int32_t#)zip->cd_sizecxx . . $ mz_zip_s#cd_size.); |
| 1461 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1462 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_offsetcxx . . $ mz_zip_s#cd_offset., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1463 | } else { |
| 1464 | if (zip->cd_signaturecxx . . $ mz_zip_s#cd_signature. == MZ_ZIP_MAGIC_ENDHEADERcxx . . $ `mz_zip.c:63:9`!) { |
| 1465 | /* If tiny zip then overwrite end header */ |
| 1466 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->cd_offsetcxx . . $ mz_zip_s#cd_offset., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1467 | } else { |
| 1468 | /* If no central directory, append new zip to end of file */ |
| 1469 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., 0, MZ_SEEK_ENDcxx . . $ `mz.h:60:9`!); |
| 1470 | } |
| 1471 | } |
| 1472 | |
| 1473 | if (zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. > 0) { |
| 1474 | /* Move to last disk to begin appending */ |
| 1475 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. - 1); |
| 1476 | } |
| 1477 | } else { |
| 1478 | zip->cd_start_poscxx . . $ mz_zip_s#cd_start_pos. = zip->cd_offsetcxx . . $ mz_zip_s#cd_offset.; |
| 1479 | } |
| 1480 | } |
| 1481 | |
| 1482 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1483 | mz_zip_closecxx . . $ mz_zip_close(dedf1e9b1c614a07).(zip); |
| 1484 | return err; |
| 1485 | } |
| 1486 | |
| 1487 | /* Memory streams used to store variable length file info data */ |
| 1488 | zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1489 | if (!zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.) |
| 1490 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1491 | |
| 1492 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1493 | |
| 1494 | zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream. = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 1495 | if (!zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.) { |
| 1496 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1497 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1498 | } |
| 1499 | |
| 1500 | mz_stream_mem_opencxx . . $ mz_stream_mem_open(7083a8984c0735e8).(zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, MZ_OPEN_MODE_CREATEcxx . . $ `mz.h:54:9`!); |
| 1501 | |
| 1502 | zip->open_modecxx . . $ mz_zip_s#open_mode. = mode; |
| 1503 | |
| 1504 | return err; |
| 1505 | } |
| 1506 | |
| 1507 | int32_tcxx . . $ int32_t# mz_zip_closecxx . . $ mz_zip_close(dedf1e9b1c614a07).(void *handle) { |
| 1508 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1509 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1510 | |
| 1511 | if (!zip) |
| 1512 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1513 | |
| 1514 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Close\n"); |
| 1515 | |
| 1516 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1517 | err = mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(handle); |
| 1518 | |
| 1519 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!)) |
| 1520 | err = mz_zip_write_cdcxx . . $ mz_zip_write_cd(dedf1e9b1c614a07).(handle); |
| 1521 | |
| 1522 | if (zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.) { |
| 1523 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.); |
| 1524 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.); |
| 1525 | } |
| 1526 | |
| 1527 | if (zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.) { |
| 1528 | mz_stream_mem_closecxx . . $ mz_stream_mem_close(dedf1e9b1c614a07).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1529 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1530 | } |
| 1531 | if (zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.) { |
| 1532 | mz_stream_mem_closecxx . . $ mz_stream_mem_close(dedf1e9b1c614a07).(zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.); |
| 1533 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.); |
| 1534 | } |
| 1535 | |
| 1536 | if (zip->commentcxx . . $ mz_zip_s#comment.) { |
| 1537 | freecxx . . $ free(5d22bdacc48458e8).(zip->commentcxx . . $ mz_zip_s#comment.); |
| 1538 | zip->commentcxx . . $ mz_zip_s#comment. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1539 | } |
| 1540 | |
| 1541 | zip->streamcxx . . $ mz_zip_s#stream. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1542 | zip->cd_streamcxx . . $ mz_zip_s#cd_stream. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1543 | |
| 1544 | return err; |
| 1545 | } |
| 1546 | |
| 1547 | int32_tcxx . . $ int32_t# mz_zip_get_commentcxx . . $ mz_zip_get_comment(1160c33587cf46c5).(void *handle, const char **comment) { |
| 1548 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1549 | if (!zip || !comment) |
| 1550 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1551 | if (!zip->commentcxx . . $ mz_zip_s#comment.) |
| 1552 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1553 | *comment = zip->commentcxx . . $ mz_zip_s#comment.; |
| 1554 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1555 | } |
| 1556 | |
| 1557 | int32_tcxx . . $ int32_t# mz_zip_set_commentcxx . . $ mz_zip_set_comment(f53b6be6549e6d95).(void *handle, const char *comment) { |
| 1558 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1559 | int32_tcxx . . $ int32_t# comment_size = 0; |
| 1560 | if (!zip || !comment) |
| 1561 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1562 | freecxx . . $ free(5d22bdacc48458e8).(zip->commentcxx . . $ mz_zip_s#comment.); |
| 1563 | comment_size = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(comment); |
| 1564 | if (comment_size > UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) |
| 1565 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1566 | zip->commentcxx . . $ mz_zip_s#comment. = (char *)calloccxx . . $ calloc(63a7bf2941bfcd7a).(comment_size + 1, sizeof(char)); |
| 1567 | if (!zip->commentcxx . . $ mz_zip_s#comment.) |
| 1568 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1569 | strncpycxx . . $ strncpy(255158a415b673b0).(zip->commentcxx . . $ mz_zip_s#comment., comment, comment_size); |
| 1570 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1571 | } |
| 1572 | |
| 1573 | int32_tcxx . . $ int32_t# mz_zip_get_version_madebycxx . . $ mz_zip_get_version_madeby(900c00eb402c9863).(void *handle, uint16_tcxx . . $ uint16_t# *version_madeby) { |
| 1574 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1575 | if (!zip || !version_madeby) |
| 1576 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1577 | *version_madeby = zip->version_madebycxx . . $ mz_zip_s#version_madeby.; |
| 1578 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1579 | } |
| 1580 | |
| 1581 | int32_tcxx . . $ int32_t# mz_zip_set_version_madebycxx . . $ mz_zip_set_version_madeby(f805ef7ae580f896).(void *handle, uint16_tcxx . . $ uint16_t# version_madeby) { |
| 1582 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1583 | if (!zip) |
| 1584 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1585 | zip->version_madebycxx . . $ mz_zip_s#version_madeby. = version_madeby; |
| 1586 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1587 | } |
| 1588 | |
| 1589 | int32_tcxx . . $ int32_t# mz_zip_set_recovercxx . . $ mz_zip_set_recover(5276b51c10b71c09).(void *handle, uint8_tcxx . . $ uint8_t# recover) { |
| 1590 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1591 | if (!zip) |
| 1592 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1593 | zip->recovercxx . . $ mz_zip_s#recover. = recover; |
| 1594 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1595 | } |
| 1596 | |
| 1597 | int32_tcxx . . $ int32_t# mz_zip_set_data_descriptorcxx . . $ mz_zip_set_data_descriptor(5276b51c10b71c09).(void *handle, uint8_tcxx . . $ uint8_t# data_descriptor) { |
| 1598 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1599 | if (!zip) |
| 1600 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1601 | zip->data_descriptorcxx . . $ mz_zip_s#data_descriptor. = data_descriptor; |
| 1602 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1603 | } |
| 1604 | |
| 1605 | int32_tcxx . . $ int32_t# mz_zip_get_streamcxx . . $ mz_zip_get_stream(1843ed636859e0d0).(void *handle, void **stream) { |
| 1606 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1607 | if (!zip || !stream) |
| 1608 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1609 | *stream = zip->streamcxx . . $ mz_zip_s#stream.; |
| 1610 | if (!*stream) |
| 1611 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1612 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1613 | } |
| 1614 | |
| 1615 | int32_tcxx . . $ int32_t# mz_zip_set_cd_streamcxx . . $ mz_zip_set_cd_stream(ebe495d140c0cd6c).(void *handle, int64_tcxx . . $ int64_t# cd_start_pos, void *cd_stream) { |
| 1616 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1617 | if (!zip || !cd_stream) |
| 1618 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1619 | zip->cd_offsetcxx . . $ mz_zip_s#cd_offset. = 0; |
| 1620 | zip->cd_streamcxx . . $ mz_zip_s#cd_stream. = cd_stream; |
| 1621 | zip->cd_start_poscxx . . $ mz_zip_s#cd_start_pos. = cd_start_pos; |
| 1622 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1623 | } |
| 1624 | |
| 1625 | int32_tcxx . . $ int32_t# mz_zip_get_cd_mem_streamcxx . . $ mz_zip_get_cd_mem_stream(1843ed636859e0d0).(void *handle, void **cd_mem_stream) { |
| 1626 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1627 | if (!zip || !cd_mem_stream) |
| 1628 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1629 | *cd_mem_stream = zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream.; |
| 1630 | if (!*cd_mem_stream) |
| 1631 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1632 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1633 | } |
| 1634 | |
| 1635 | int32_tcxx . . $ int32_t# mz_zip_set_number_entrycxx . . $ mz_zip_set_number_entry(c0a5f96701d3f89).(void *handle, uint64_tcxx . . $ uint64_t# number_entry) { |
| 1636 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1637 | if (!zip) |
| 1638 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1639 | zip->number_entrycxx . . $ mz_zip_s#number_entry. = number_entry; |
| 1640 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1641 | } |
| 1642 | |
| 1643 | int32_tcxx . . $ int32_t# mz_zip_get_number_entrycxx . . $ mz_zip_get_number_entry(17c9a57913c314f0).(void *handle, uint64_tcxx . . $ uint64_t# *number_entry) { |
| 1644 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1645 | if (!zip || !number_entry) |
| 1646 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1647 | *number_entry = zip->number_entrycxx . . $ mz_zip_s#number_entry.; |
| 1648 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1649 | } |
| 1650 | |
| 1651 | int32_tcxx . . $ int32_t# mz_zip_set_disk_number_with_cdcxx . . $ mz_zip_set_disk_number_with_cd(6fe7d876f9648735).(void *handle, uint32_tcxx . . $ uint32_t# disk_number_with_cd) { |
| 1652 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1653 | if (!zip) |
| 1654 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1655 | zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd. = disk_number_with_cd; |
| 1656 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1657 | } |
| 1658 | |
| 1659 | int32_tcxx . . $ int32_t# mz_zip_get_disk_number_with_cdcxx . . $ mz_zip_get_disk_number_with_cd(3569d74970a1d1f9).(void *handle, uint32_tcxx . . $ uint32_t# *disk_number_with_cd) { |
| 1660 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1661 | if (!zip || !disk_number_with_cd) |
| 1662 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1663 | *disk_number_with_cd = zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.; |
| 1664 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1665 | } |
| 1666 | |
| 1667 | static int32_tcxx . . $ int32_t# mz_zip_entry_close_intcxx . . $ mz_zip_entry_close_int(dedf1e9b1c614a07).(void *handle) { |
| 1668 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1669 | |
| 1670 | if (zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.) |
| 1671 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.); |
| 1672 | zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1673 | if (zip->compress_streamcxx . . $ mz_zip_s#compress_stream.) |
| 1674 | mz_stream_deletecxx . . $ mz_stream_delete(539e082cf00e1f43).(&zip->compress_streamcxx . . $ mz_zip_s#compress_stream.); |
| 1675 | zip->compress_streamcxx . . $ mz_zip_s#compress_stream. = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 1676 | |
| 1677 | zip->entry_openedcxx . . $ mz_zip_s#entry_opened. = 0; |
| 1678 | |
| 1679 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1680 | } |
| 1681 | |
| 1682 | static int32_tcxx . . $ int32_t# mz_zip_entry_open_intcxx . . $ mz_zip_entry_open_int(46789ce8649c842f).(void *handle, uint8_tcxx . . $ uint8_t# raw, int16_tcxx . . $ int16_t# compress_level, const char *password) { |
| 1683 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1684 | int64_tcxx . . $ int64_t# max_total_in = 0; |
| 1685 | int64_tcxx . . $ int64_t# header_size = 0; |
| 1686 | int64_tcxx . . $ int64_t# footer_size = 0; |
| 1687 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1688 | uint8_tcxx . . $ uint8_t# use_crypt = 0; |
| 1689 | |
| 1690 | if (!zip) |
| 1691 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1692 | |
| 1693 | switch (zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method.) { |
| 1694 | case MZ_COMPRESS_METHOD_STOREcxx . . $ `mz.h:63:9`!: |
| 1695 | case MZ_COMPRESS_METHOD_DEFLATEcxx . . $ `mz.h:64:9`!: |
| 1696 | #ifdef HAVE_BZIP2 |
| 1697 | case MZ_COMPRESS_METHOD_BZIP2: |
| 1698 | #endif |
| 1699 | #ifdef HAVE_LZMA |
| 1700 | case MZ_COMPRESS_METHOD_LZMA: |
| 1701 | #endif |
| 1702 | #if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) |
| 1703 | case MZ_COMPRESS_METHOD_XZ: |
| 1704 | #endif |
| 1705 | #ifdef HAVE_ZSTD |
| 1706 | case MZ_COMPRESS_METHOD_ZSTD: |
| 1707 | #endif |
| 1708 | err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1709 | break; |
| 1710 | default: |
| 1711 | return MZ_SUPPORT_ERRORcxx . . $ `mz.h:38:9`!; |
| 1712 | } |
| 1713 | |
| 1714 | #ifndef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 1715 | if (zip->file_info.aes_version) |
| 1716 | return MZ_SUPPORT_ERROR; |
| 1717 | #endif |
| 1718 | |
| 1719 | zip->entry_rawcxx . . $ mz_zip_s#entry_raw. = raw; |
| 1720 | |
| 1721 | if ((zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) && (password)) { |
| 1722 | if (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) { |
| 1723 | /* Encrypt only when we are not trying to write raw and password is supplied. */ |
| 1724 | if (!zip->entry_rawcxx . . $ mz_zip_s#entry_raw.) |
| 1725 | use_crypt = 1; |
| 1726 | } else if (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!) { |
| 1727 | /* Decrypt only when password is supplied. Don't error when password */ |
| 1728 | /* is not supplied as we may want to read the raw encrypted data. */ |
| 1729 | use_crypt = 1; |
| 1730 | } |
| 1731 | } |
| 1732 | |
| 1733 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (use_crypt)) { |
| 1734 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 1735 | if (zip->file_infocxx . . $ mz_zip_s#file_info..aes_versioncxx . . $ mz_zip_file_s#aes_version.) { |
| 1736 | zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream. = mz_stream_wzaes_createcxx . . $ mz_stream_wzaes_create(50c7df7de5344ebb).(); |
| 1737 | if (!zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.) |
| 1738 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1739 | mz_stream_wzaes_set_passwordcxx . . $ mz_stream_wzaes_set_password(e7c9eaecdb7c5ce7).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., password); |
| 1740 | mz_stream_wzaes_set_strengthcxx . . $ mz_stream_wzaes_set_strength(5b3d32ff749dfd74).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., zip->file_infocxx . . $ mz_zip_s#file_info..aes_strengthcxx . . $ mz_zip_file_s#aes_strength.); |
| 1741 | } else |
| 1742 | #endif |
| 1743 | { |
| 1744 | #ifdef HAVE_PKCRYPTcxx . . $ `<built-in>:414:9`! |
| 1745 | uint8_tcxx . . $ uint8_t# verify1 = (uint8_tcxx . . $ uint8_t#)((zip->file_infocxx . . $ mz_zip_s#file_info..pk_verifycxx . . $ mz_zip_file_s#pk_verify. >> 8) & 0xff); |
| 1746 | uint8_tcxx . . $ uint8_t# verify2 = (uint8_tcxx . . $ uint8_t#)((zip->file_infocxx . . $ mz_zip_s#file_info..pk_verifycxx . . $ mz_zip_file_s#pk_verify.) & 0xff); |
| 1747 | |
| 1748 | zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream. = mz_stream_pkcrypt_createcxx . . $ mz_stream_pkcrypt_create(50c7df7de5344ebb).(); |
| 1749 | if (!zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.) |
| 1750 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1751 | mz_stream_pkcrypt_set_passwordcxx . . $ mz_stream_pkcrypt_set_password(e7c9eaecdb7c5ce7).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., password); |
| 1752 | mz_stream_pkcrypt_set_verifycxx . . $ mz_stream_pkcrypt_set_verify(1dee36ffbd7c6497).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., verify1, verify2, zip->file_infocxx . . $ mz_zip_s#file_info..version_neededcxx . . $ mz_zip_file_s#version_needed.); |
| 1753 | #endif |
| 1754 | } |
| 1755 | } |
| 1756 | |
| 1757 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1758 | if (!zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.) |
| 1759 | zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream. = mz_stream_raw_createcxx . . $ mz_stream_raw_create(50c7df7de5344ebb).(); |
| 1760 | if (!zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.) |
| 1761 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1762 | |
| 1763 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., zip->streamcxx . . $ mz_zip_s#stream.); |
| 1764 | |
| 1765 | err = mz_stream_opencxx . . $ mz_stream_open(7083a8984c0735e8).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, zip->open_modecxx . . $ mz_zip_s#open_mode.); |
| 1766 | } |
| 1767 | |
| 1768 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1769 | if (zip->entry_rawcxx . . $ mz_zip_s#entry_raw. || zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method. == MZ_COMPRESS_METHOD_STOREcxx . . $ `mz.h:63:9`!) |
| 1770 | zip->compress_streamcxx . . $ mz_zip_s#compress_stream. = mz_stream_raw_createcxx . . $ mz_stream_raw_create(50c7df7de5344ebb).(); |
| 1771 | #ifdef HAVE_ZLIBcxx . . $ `<built-in>:417:9`! |
| 1772 | else if (zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method. == MZ_COMPRESS_METHOD_DEFLATEcxx . . $ `mz.h:64:9`!) |
| 1773 | zip->compress_streamcxx . . $ mz_zip_s#compress_stream. = mz_stream_zlib_createcxx . . $ mz_stream_zlib_create(50c7df7de5344ebb).(); |
| 1774 | #endif |
| 1775 | #ifdef HAVE_BZIP2 |
| 1776 | else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_BZIP2) |
| 1777 | zip->compress_stream = mz_stream_bzip_create(); |
| 1778 | #endif |
| 1779 | #ifdef HAVE_LIBCOMP |
| 1780 | else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_DEFLATE || |
| 1781 | zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { |
| 1782 | zip->compress_stream = mz_stream_libcomp_create(); |
| 1783 | if (zip->compress_stream) { |
| 1784 | mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, |
| 1785 | zip->file_info.compression_method); |
| 1786 | } |
| 1787 | } |
| 1788 | #endif |
| 1789 | #ifdef HAVE_LZMA |
| 1790 | else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA || |
| 1791 | zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) { |
| 1792 | zip->compress_stream = mz_stream_lzma_create(); |
| 1793 | if (zip->compress_stream) { |
| 1794 | mz_stream_set_prop_int64(zip->compress_stream, MZ_STREAM_PROP_COMPRESS_METHOD, |
| 1795 | zip->file_info.compression_method); |
| 1796 | } |
| 1797 | } |
| 1798 | #endif |
| 1799 | #ifdef HAVE_ZSTD |
| 1800 | else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_ZSTD) |
| 1801 | zip->compress_stream = mz_stream_zstd_create(); |
| 1802 | #endif |
| 1803 | else |
| 1804 | err = MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1805 | } |
| 1806 | |
| 1807 | if (err == MZ_OKcxx . . $ `mz.h:21:9`! && !zip->compress_streamcxx . . $ mz_zip_s#compress_stream.) |
| 1808 | err = MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 1809 | |
| 1810 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1811 | if (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) { |
| 1812 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_COMPRESS_LEVELcxx . . $ `mz_strm.h:28:9`!, compress_level); |
| 1813 | } else { |
| 1814 | int32_tcxx . . $ int32_t# set_end_of_stream = 0; |
| 1815 | |
| 1816 | #ifndef HAVE_LIBCOMP |
| 1817 | if (zip->entry_rawcxx . . $ mz_zip_s#entry_raw. || zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method. == MZ_COMPRESS_METHOD_STOREcxx . . $ `mz.h:63:9`! || |
| 1818 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) |
| 1819 | #endif |
| 1820 | { |
| 1821 | max_total_in = zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size.; |
| 1822 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., MZ_STREAM_PROP_TOTAL_IN_MAXcxx . . $ `mz_strm.h:21:9`!, max_total_in); |
| 1823 | |
| 1824 | if (mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., MZ_STREAM_PROP_HEADER_SIZEcxx . . $ `mz_strm.h:24:9`!, &header_size) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1825 | max_total_in -= header_size; |
| 1826 | if (mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., MZ_STREAM_PROP_FOOTER_SIZEcxx . . $ `mz_strm.h:25:9`!, &footer_size) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1827 | max_total_in -= footer_size; |
| 1828 | |
| 1829 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_IN_MAXcxx . . $ `mz_strm.h:21:9`!, max_total_in); |
| 1830 | } |
| 1831 | |
| 1832 | switch (zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method.) { |
| 1833 | case MZ_COMPRESS_METHOD_LZMAcxx . . $ `mz.h:66:9`!: |
| 1834 | case MZ_COMPRESS_METHOD_XZcxx . . $ `mz.h:68:9`!: |
| 1835 | set_end_of_stream = (zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_LZMA_EOS_MARKERcxx . . $ `mz.h:78:9`!); |
| 1836 | break; |
| 1837 | case MZ_COMPRESS_METHOD_ZSTDcxx . . $ `mz.h:67:9`!: |
| 1838 | set_end_of_stream = 1; |
| 1839 | break; |
| 1840 | } |
| 1841 | |
| 1842 | if (set_end_of_stream) { |
| 1843 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_IN_MAXcxx . . $ `mz_strm.h:21:9`!, |
| 1844 | zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size.); |
| 1845 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_OUT_MAXcxx . . $ `mz_strm.h:23:9`!, |
| 1846 | zip->file_infocxx . . $ mz_zip_s#file_info..uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 1847 | } |
| 1848 | } |
| 1849 | |
| 1850 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.); |
| 1851 | |
| 1852 | err = mz_stream_opencxx . . $ mz_stream_open(7083a8984c0735e8).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, zip->open_modecxx . . $ mz_zip_s#open_mode.); |
| 1853 | } |
| 1854 | |
| 1855 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1856 | zip->entry_openedcxx . . $ mz_zip_s#entry_opened. = 1; |
| 1857 | zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32. = 0; |
| 1858 | } else { |
| 1859 | mz_zip_entry_close_intcxx . . $ mz_zip_entry_close_int(dedf1e9b1c614a07).(handle); |
| 1860 | } |
| 1861 | |
| 1862 | return err; |
| 1863 | } |
| 1864 | |
| 1865 | int32_tcxx . . $ int32_t# mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(void *handle) { |
| 1866 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1867 | if (!zip) |
| 1868 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1869 | if (zip->entry_openedcxx . . $ mz_zip_s#entry_opened. == 0) |
| 1870 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 1871 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1872 | } |
| 1873 | |
| 1874 | int32_tcxx . . $ int32_t# mz_zip_entry_read_opencxx . . $ mz_zip_entry_read_open(5e2f72b4b9a4e6c4).(void *handle, uint8_tcxx . . $ uint8_t# raw, const char *password) { |
| 1875 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1876 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1877 | int32_tcxx . . $ int32_t# err_shift = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1878 | |
| 1879 | #if defined(MZ_ZIP_NO_ENCRYPTION) |
| 1880 | if (password) |
| 1881 | return MZ_SUPPORT_ERROR; |
| 1882 | #endif |
| 1883 | if (!zip || !zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned.) |
| 1884 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1885 | if ((zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_READcxx . . $ `mz.h:50:9`!) == 0) |
| 1886 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1887 | |
| 1888 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read open (raw %" PRId32 ")\n", raw); |
| 1889 | |
| 1890 | err = mz_zip_entry_seek_local_headercxx . . $ mz_zip_entry_seek_local_header(dedf1e9b1c614a07).(handle); |
| 1891 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1892 | err = mz_zip_entry_read_headercxx . . $ mz_zip_entry_read_header(22e9f4de044eb2c0).(zip->streamcxx . . $ mz_zip_s#stream., 1, &zip->local_file_infocxx . . $ mz_zip_s#local_file_info., zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.); |
| 1893 | |
| 1894 | if (err == MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`! && zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift. > 0) { |
| 1895 | /* Perhaps we didn't compensated correctly for incorrect cd offset */ |
| 1896 | err_shift = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->file_infocxx . . $ mz_zip_s#file_info..disk_offsetcxx . . $ mz_zip_file_s#disk_offset., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1897 | if (err_shift == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1898 | err_shift = mz_zip_entry_read_headercxx . . $ mz_zip_entry_read_header(22e9f4de044eb2c0).(zip->streamcxx . . $ mz_zip_s#stream., 1, &zip->local_file_infocxx . . $ mz_zip_s#local_file_info., zip->local_file_info_streamcxx . . $ mz_zip_s#local_file_info_stream.); |
| 1899 | if (err_shift == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1900 | zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift. = 0; |
| 1901 | err = err_shift; |
| 1902 | } |
| 1903 | } |
| 1904 | |
| 1905 | #ifdef MZ_ZIP_NO_DECOMPRESSION |
| 1906 | if (!raw && zip->file_info.compression_method != MZ_COMPRESS_METHOD_STORE) |
| 1907 | err = MZ_SUPPORT_ERROR; |
| 1908 | #endif |
| 1909 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1910 | err = mz_zip_entry_open_intcxx . . $ mz_zip_entry_open_int(46789ce8649c842f).(handle, raw, 0, password); |
| 1911 | |
| 1912 | return err; |
| 1913 | } |
| 1914 | |
| 1915 | int32_tcxx . . $ int32_t# mz_zip_entry_write_opencxx . . $ mz_zip_entry_write_open(20cb44e2e54ec293).(void *handle, const mz_zip_filecxx . . $ mz_zip_file# *file_info, int16_tcxx . . $ int16_t# compress_level, uint8_tcxx . . $ uint8_t# raw, |
| 1916 | const char *password) { |
| 1917 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 1918 | int64_tcxx . . $ int64_t# filename_pos = -1; |
| 1919 | int64_tcxx . . $ int64_t# extrafield_pos = 0; |
| 1920 | int64_tcxx . . $ int64_t# comment_pos = 0; |
| 1921 | int64_tcxx . . $ int64_t# linkname_pos = 0; |
| 1922 | int64_tcxx . . $ int64_t# disk_number = 0; |
| 1923 | uint8_tcxx . . $ uint8_t# is_dir = 0; |
| 1924 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 1925 | |
| 1926 | #if defined(MZ_ZIP_NO_ENCRYPTION) |
| 1927 | if (password) |
| 1928 | return MZ_SUPPORT_ERROR; |
| 1929 | #endif |
| 1930 | if (!zip || !file_info || !file_info->filenamecxx . . $ mz_zip_file_s#filename.) |
| 1931 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 1932 | |
| 1933 | if (mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 1934 | err = mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(handle); |
| 1935 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1936 | return err; |
| 1937 | } |
| 1938 | |
| 1939 | memcpycxx . . $ memcpy(cc817cb175f282d).(&zip->file_infocxx . . $ mz_zip_s#file_info., file_info, sizeof(mz_zip_filecxx . . $ mz_zip_file#)); |
| 1940 | |
| 1941 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Write open - %s (level %" PRId16 " raw %" PRId8 ")\n", zip->file_info.filename, |
| 1942 | compress_level, raw); |
| 1943 | |
| 1944 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., 0, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 1945 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., file_info, sizeof(mz_zip_filecxx . . $ mz_zip_file#)); |
| 1946 | |
| 1947 | /* Copy filename, extrafield, and comment internally */ |
| 1948 | filename_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1949 | if (file_info->filenamecxx . . $ mz_zip_file_s#filename.) |
| 1950 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., file_info->filenamecxx . . $ mz_zip_file_s#filename., (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(file_info->filenamecxx . . $ mz_zip_file_s#filename.)); |
| 1951 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., 0); |
| 1952 | |
| 1953 | extrafield_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1954 | if (file_info->extrafieldcxx . . $ mz_zip_file_s#extrafield.) |
| 1955 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., file_info->extrafieldcxx . . $ mz_zip_file_s#extrafield., file_info->extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size.); |
| 1956 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., 0); |
| 1957 | |
| 1958 | comment_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1959 | if (file_info->commentcxx . . $ mz_zip_file_s#comment.) |
| 1960 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., file_info->commentcxx . . $ mz_zip_file_s#comment., file_info->comment_sizecxx . . $ mz_zip_file_s#comment_size.); |
| 1961 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., 0); |
| 1962 | |
| 1963 | linkname_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 1964 | if (file_info->linknamecxx . . $ mz_zip_file_s#linkname.) |
| 1965 | mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., file_info->linknamecxx . . $ mz_zip_file_s#linkname., (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(file_info->linknamecxx . . $ mz_zip_file_s#linkname.)); |
| 1966 | mz_stream_write_uint8cxx . . $ mz_stream_write_uint8(5276b51c10b71c09).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., 0); |
| 1967 | |
| 1968 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., filename_pos, (const void **)&zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename.); |
| 1969 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., extrafield_pos, (const void **)&zip->file_infocxx . . $ mz_zip_s#file_info..extrafieldcxx . . $ mz_zip_file_s#extrafield.); |
| 1970 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., comment_pos, (const void **)&zip->file_infocxx . . $ mz_zip_s#file_info..commentcxx . . $ mz_zip_file_s#comment.); |
| 1971 | mz_stream_mem_get_buffer_atcxx . . $ mz_stream_mem_get_buffer_at(46b739f8dccdd346).(zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream., linkname_pos, (const void **)&zip->file_infocxx . . $ mz_zip_s#file_info..linknamecxx . . $ mz_zip_file_s#linkname.); |
| 1972 | |
| 1973 | if (zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method. == MZ_COMPRESS_METHOD_DEFLATEcxx . . $ `mz.h:64:9`!) { |
| 1974 | if ((compress_level == 8) || (compress_level == 9)) |
| 1975 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_DEFLATE_MAXcxx . . $ `mz.h:79:9`!; |
| 1976 | if (compress_level == 2) |
| 1977 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_DEFLATE_FASTcxx . . $ `mz.h:81:9`!; |
| 1978 | if (compress_level == 1) |
| 1979 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_DEFLATE_SUPER_FASTcxx . . $ `mz.h:82:9`!; |
| 1980 | } |
| 1981 | #if defined(HAVE_LZMA) || defined(HAVE_LIBCOMP) |
| 1982 | else if (zip->file_info.compression_method == MZ_COMPRESS_METHOD_LZMA || |
| 1983 | zip->file_info.compression_method == MZ_COMPRESS_METHOD_XZ) |
| 1984 | zip->file_info.flag |= MZ_ZIP_FLAG_LZMA_EOS_MARKER; |
| 1985 | #endif |
| 1986 | |
| 1987 | if (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(zip->file_infocxx . . $ mz_zip_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., zip->file_infocxx . . $ mz_zip_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 1988 | is_dir = 1; |
| 1989 | |
| 1990 | if (!raw && !is_dir) { |
| 1991 | if (zip->data_descriptorcxx . . $ mz_zip_s#data_descriptor.) |
| 1992 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!; |
| 1993 | if (password) |
| 1994 | zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. |= MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!; |
| 1995 | } |
| 1996 | |
| 1997 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, &disk_number); |
| 1998 | zip->file_infocxx . . $ mz_zip_s#file_info..disk_numbercxx . . $ mz_zip_file_s#disk_number. = (uint32_tcxx . . $ uint32_t#)disk_number; |
| 1999 | zip->file_infocxx . . $ mz_zip_s#file_info..disk_offsetcxx . . $ mz_zip_file_s#disk_offset. = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 2000 | |
| 2001 | if (zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) { |
| 2002 | #ifdef HAVE_PKCRYPTcxx . . $ `<built-in>:414:9`! |
| 2003 | /* Pre-calculated CRC value is required for PKWARE traditional encryption */ |
| 2004 | uint32_tcxx . . $ uint32_t# dos_date = mz_zip_time_t_to_dos_datecxx . . $ mz_zip_time_t_to_dos_date(bd267e0bd5a0c68b).(zip->file_infocxx . . $ mz_zip_s#file_info..modified_datecxx . . $ mz_zip_file_s#modified_date.); |
| 2005 | zip->file_infocxx . . $ mz_zip_s#file_info..pk_verifycxx . . $ mz_zip_file_s#pk_verify. = mz_zip_get_pk_verifycxx . . $ mz_zip_get_pk_verify(ff658ccb6c36c729).(dos_date, zip->file_infocxx . . $ mz_zip_s#file_info..crccxx . . $ mz_zip_file_s#crc., zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag.); |
| 2006 | #endif |
| 2007 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 2008 | if (zip->file_infocxx . . $ mz_zip_s#file_info..aes_versioncxx . . $ mz_zip_file_s#aes_version. && zip->file_infocxx . . $ mz_zip_s#file_info..aes_strengthcxx . . $ mz_zip_file_s#aes_strength. == 0) |
| 2009 | zip->file_infocxx . . $ mz_zip_s#file_info..aes_strengthcxx . . $ mz_zip_file_s#aes_strength. = MZ_AES_STRENGTH_256cxx . . $ `mz.h:119:9`!; |
| 2010 | #endif |
| 2011 | } |
| 2012 | |
| 2013 | zip->file_infocxx . . $ mz_zip_s#file_info..crccxx . . $ mz_zip_file_s#crc. = 0; |
| 2014 | zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size. = 0; |
| 2015 | |
| 2016 | if ((compress_level == 0) || (is_dir)) |
| 2017 | zip->file_infocxx . . $ mz_zip_s#file_info..compression_methodcxx . . $ mz_zip_file_s#compression_method. = MZ_COMPRESS_METHOD_STOREcxx . . $ `mz.h:63:9`!; |
| 2018 | |
| 2019 | #ifdef MZ_ZIP_NO_COMPRESSION |
| 2020 | if (zip->file_info.compression_method != MZ_COMPRESS_METHOD_STORE) |
| 2021 | err = MZ_SUPPORT_ERROR; |
| 2022 | #endif |
| 2023 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2024 | err = mz_zip_entry_write_headercxx . . $ mz_zip_entry_write_header(c37012eda6503356).(zip->streamcxx . . $ mz_zip_s#stream., 1, &zip->file_infocxx . . $ mz_zip_s#file_info.); |
| 2025 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2026 | err = mz_zip_entry_open_intcxx . . $ mz_zip_entry_open_int(46789ce8649c842f).(handle, raw, compress_level, password); |
| 2027 | |
| 2028 | return err; |
| 2029 | } |
| 2030 | |
| 2031 | int32_tcxx . . $ int32_t# mz_zip_entry_readcxx . . $ mz_zip_entry_read(8bc41909eac9e5d8).(void *handle, void *buf, int32_tcxx . . $ int32_t# len) { |
| 2032 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2033 | int32_tcxx . . $ int32_t# read = 0; |
| 2034 | |
| 2035 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2036 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2037 | if (UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`! == UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`! && len > UINT16_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:117:10`!) /* zlib limitation */ |
| 2038 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2039 | if (len == 0) |
| 2040 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2041 | |
| 2042 | if (zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size. == 0) |
| 2043 | return 0; |
| 2044 | |
| 2045 | /* Read entire entry even if uncompressed_size = 0, otherwise */ |
| 2046 | /* aes encryption validation will fail if compressed_size > 0 */ |
| 2047 | read = mz_stream_readcxx . . $ mz_stream_read(8bc41909eac9e5d8).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., buf, len); |
| 2048 | if (read > 0) |
| 2049 | zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32. = mz_crypt_crc32_updatecxx . . $ mz_crypt_crc32_update(c72eefe6f8c9ad5).(zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32., buf, read); |
| 2050 | |
| 2051 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read - %" PRId32 " (max %" PRId32 ")\n", read, len); |
| 2052 | |
| 2053 | return read; |
| 2054 | } |
| 2055 | |
| 2056 | int32_tcxx . . $ int32_t# mz_zip_entry_writecxx . . $ mz_zip_entry_write(91e54fd90adbb21).(void *handle, const void *buf, int32_tcxx . . $ int32_t# len) { |
| 2057 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2058 | int32_tcxx . . $ int32_t# written = 0; |
| 2059 | |
| 2060 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2061 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2062 | written = mz_stream_writecxx . . $ mz_stream_write(91e54fd90adbb21).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., buf, len); |
| 2063 | if (written > 0) |
| 2064 | zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32. = mz_crypt_crc32_updatecxx . . $ mz_crypt_crc32_update(c72eefe6f8c9ad5).(zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32., buf, written); |
| 2065 | |
| 2066 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Write - %" PRId32 " (max %" PRId32 ")\n", written, len); |
| 2067 | return written; |
| 2068 | } |
| 2069 | |
| 2070 | int32_tcxx . . $ int32_t# mz_zip_entry_read_closecxx . . $ mz_zip_entry_read_close(f358a56cc8c9350).(void *handle, uint32_tcxx . . $ uint32_t# *crc32, int64_tcxx . . $ int64_t# *compressed_size, int64_tcxx . . $ int64_t# *uncompressed_size) { |
| 2071 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2072 | int64_tcxx . . $ int64_t# total_in = 0; |
| 2073 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2074 | uint8_tcxx . . $ uint8_t# zip64 = 0; |
| 2075 | |
| 2076 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2077 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2078 | |
| 2079 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream.); |
| 2080 | |
| 2081 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Read Close\n"); |
| 2082 | |
| 2083 | if (crc32) |
| 2084 | *crc32 = zip->file_infocxx . . $ mz_zip_s#file_info..crccxx . . $ mz_zip_file_s#crc.; |
| 2085 | if (compressed_size) |
| 2086 | *compressed_size = zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size.; |
| 2087 | if (uncompressed_size) |
| 2088 | *uncompressed_size = zip->file_infocxx . . $ mz_zip_s#file_info..uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.; |
| 2089 | |
| 2090 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_INcxx . . $ `mz_strm.h:20:9`!, &total_in); |
| 2091 | |
| 2092 | if ((zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!) && |
| 2093 | ((zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_MASK_LOCAL_INFOcxx . . $ `mz.h:85:9`!) == 0) && (crc32 || compressed_size || uncompressed_size)) { |
| 2094 | /* Check to see if data descriptor is zip64 bit format or not */ |
| 2095 | if (mz_zip_extrafield_containscxx . . $ mz_zip_extrafield_contains(b9c376550f650e).(zip->local_file_infocxx . . $ mz_zip_s#local_file_info..extrafieldcxx . . $ mz_zip_file_s#extrafield., zip->local_file_infocxx . . $ mz_zip_s#local_file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size., |
| 2096 | MZ_ZIP_EXTENSION_ZIP64cxx . . $ `mz.h:88:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!) == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2097 | zip64 = 1; |
| 2098 | } |
| 2099 | |
| 2100 | err = mz_zip_entry_seek_local_headercxx . . $ mz_zip_entry_seek_local_header(dedf1e9b1c614a07).(handle); |
| 2101 | |
| 2102 | /* Seek to end of compressed stream since we might have over-read during compression */ |
| 2103 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2104 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., |
| 2105 | MZ_ZIP_SIZE_LD_ITEMcxx . . $ `mz_zip.c:70:9`! + (int64_tcxx . . $ int64_t#)zip->local_file_infocxx . . $ mz_zip_s#local_file_info..filename_sizecxx . . $ mz_zip_file_s#filename_size. + |
| 2106 | (int64_tcxx . . $ int64_t#)zip->local_file_infocxx . . $ mz_zip_s#local_file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. + total_in, |
| 2107 | MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 2108 | } |
| 2109 | |
| 2110 | /* Read data descriptor */ |
| 2111 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2112 | err = mz_zip_entry_read_descriptorcxx . . $ mz_zip_entry_read_descriptor(f7c6753e6a4e27a9).(zip->streamcxx . . $ mz_zip_s#stream., zip64, crc32, compressed_size, uncompressed_size); |
| 2113 | } |
| 2114 | |
| 2115 | /* If entire entry was not read verification will fail */ |
| 2116 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (total_in == zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size.) && (!zip->entry_rawcxx . . $ mz_zip_s#entry_raw.)) { |
| 2117 | #ifdef HAVE_WZAEScxx . . $ `<built-in>:416:9`! |
| 2118 | /* AES zip version AE-1 will expect a valid crc as well */ |
| 2119 | if (zip->file_infocxx . . $ mz_zip_s#file_info..aes_versioncxx . . $ mz_zip_file_s#aes_version. <= 0x0001) |
| 2120 | #endif |
| 2121 | { |
| 2122 | if (zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32. != zip->file_infocxx . . $ mz_zip_s#file_info..crccxx . . $ mz_zip_file_s#crc.) { |
| 2123 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Crc failed (actual 0x%08" PRIx32 " expected 0x%08" PRIx32 ")\n", |
| 2124 | zip->entry_crc32, zip->file_info.crc); |
| 2125 | |
| 2126 | err = MZ_CRC_ERRORcxx . . $ `mz.h:34:9`!; |
| 2127 | } |
| 2128 | } |
| 2129 | } |
| 2130 | |
| 2131 | mz_zip_entry_close_intcxx . . $ mz_zip_entry_close_int(dedf1e9b1c614a07).(handle); |
| 2132 | |
| 2133 | return err; |
| 2134 | } |
| 2135 | |
| 2136 | int32_tcxx . . $ int32_t# mz_zip_entry_write_closecxx . . $ mz_zip_entry_write_close(b4f223597101ed9a).(void *handle, uint32_tcxx . . $ uint32_t# crc32, int64_tcxx . . $ int64_t# compressed_size, int64_tcxx . . $ int64_t# uncompressed_size) { |
| 2137 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2138 | int64_tcxx . . $ int64_t# end_disk_number = 0; |
| 2139 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2140 | uint8_tcxx . . $ uint8_t# zip64 = 0; |
| 2141 | |
| 2142 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2143 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2144 | |
| 2145 | mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream.); |
| 2146 | |
| 2147 | if (!zip->entry_rawcxx . . $ mz_zip_s#entry_raw.) |
| 2148 | crc32 = zip->entry_crc32cxx . . $ mz_zip_s#entry_crc32.; |
| 2149 | |
| 2150 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Write Close (crc 0x%08" PRIx32 " cs %" PRId64 " ucs %" PRId64 ")\n", crc32, |
| 2151 | compressed_size, uncompressed_size); |
| 2152 | |
| 2153 | /* If sizes are not set, then read them from the compression stream */ |
| 2154 | if (compressed_size < 0) |
| 2155 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_OUTcxx . . $ `mz_strm.h:22:9`!, &compressed_size); |
| 2156 | if (uncompressed_size < 0) |
| 2157 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->compress_streamcxx . . $ mz_zip_s#compress_stream., MZ_STREAM_PROP_TOTAL_INcxx . . $ `mz_strm.h:20:9`!, &uncompressed_size); |
| 2158 | |
| 2159 | if (zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_ENCRYPTEDcxx . . $ `mz.h:77:9`!) { |
| 2160 | mz_stream_set_basecxx . . $ mz_stream_set_base(361d5d7064a2a85d).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., zip->streamcxx . . $ mz_zip_s#stream.); |
| 2161 | err = mz_stream_closecxx . . $ mz_stream_close(dedf1e9b1c614a07).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream.); |
| 2162 | |
| 2163 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->crypt_streamcxx . . $ mz_zip_s#crypt_stream., MZ_STREAM_PROP_TOTAL_OUTcxx . . $ `mz_strm.h:22:9`!, &compressed_size); |
| 2164 | } |
| 2165 | |
| 2166 | mz_zip_entry_needs_zip64cxx . . $ mz_zip_entry_needs_zip64(503c767ff7c90557).(&zip->file_infocxx . . $ mz_zip_s#file_info., 1, &zip64); |
| 2167 | |
| 2168 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!)) { |
| 2169 | /* Determine if we need to write data descriptor in zip64 format, |
| 2170 | if local extrafield was saved with zip64 extrafield */ |
| 2171 | |
| 2172 | if (zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_MASK_LOCAL_INFOcxx . . $ `mz.h:85:9`!) |
| 2173 | err = mz_zip_entry_write_descriptorcxx . . $ mz_zip_entry_write_descriptor(d9f1f10a766e3bb4).(zip->streamcxx . . $ mz_zip_s#stream., zip64, 0, compressed_size, 0); |
| 2174 | else |
| 2175 | err = mz_zip_entry_write_descriptorcxx . . $ mz_zip_entry_write_descriptor(d9f1f10a766e3bb4).(zip->streamcxx . . $ mz_zip_s#stream., zip64, crc32, compressed_size, uncompressed_size); |
| 2176 | } |
| 2177 | |
| 2178 | /* Write file info to central directory */ |
| 2179 | |
| 2180 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Write cd (ucs %" PRId64 " cs %" PRId64 " crc 0x%08" PRIx32 ")\n", uncompressed_size, |
| 2181 | compressed_size, crc32); |
| 2182 | |
| 2183 | zip->file_infocxx . . $ mz_zip_s#file_info..crccxx . . $ mz_zip_file_s#crc. = crc32; |
| 2184 | zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size. = compressed_size; |
| 2185 | zip->file_infocxx . . $ mz_zip_s#file_info..uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size. = uncompressed_size; |
| 2186 | |
| 2187 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2188 | err = mz_zip_entry_write_headercxx . . $ mz_zip_entry_write_header(c37012eda6503356).(zip->cd_mem_streamcxx . . $ mz_zip_s#cd_mem_stream., 0, &zip->file_infocxx . . $ mz_zip_s#file_info.); |
| 2189 | |
| 2190 | /* Update local header with crc32 and sizes */ |
| 2191 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && ((zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_DATA_DESCRIPTORcxx . . $ `mz.h:83:9`!) == 0) && |
| 2192 | ((zip->file_infocxx . . $ mz_zip_s#file_info..flagcxx . . $ mz_zip_file_s#flag. & MZ_ZIP_FLAG_MASK_LOCAL_INFOcxx . . $ `mz.h:85:9`!) == 0)) { |
| 2193 | /* Save the disk number and position we are to seek back after updating local header */ |
| 2194 | int64_tcxx . . $ int64_t# end_pos = mz_stream_tellcxx . . $ mz_stream_tell(72c1818a5177f981).(zip->streamcxx . . $ mz_zip_s#stream.); |
| 2195 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, &end_disk_number); |
| 2196 | |
| 2197 | err = mz_zip_entry_seek_local_headercxx . . $ mz_zip_entry_seek_local_header(dedf1e9b1c614a07).(handle); |
| 2198 | |
| 2199 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2200 | /* Seek to crc32 and sizes offset in local header */ |
| 2201 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, zip->file_infocxx . . $ mz_zip_s#file_info..disk_numbercxx . . $ mz_zip_file_s#disk_number.); |
| 2202 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->file_infocxx . . $ mz_zip_s#file_info..disk_offsetcxx . . $ mz_zip_file_s#disk_offset. + MZ_ZIP_OFFSET_CRC_SIZEScxx . . $ `mz_zip.c:75:9`!, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 2203 | } |
| 2204 | |
| 2205 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2206 | err = mz_zip_entry_write_crc_sizescxx . . $ mz_zip_entry_write_crc_sizes(f71525ca20a31c0e).(zip->streamcxx . . $ mz_zip_s#stream., zip64, 0, &zip->file_infocxx . . $ mz_zip_s#file_info.); |
| 2207 | |
| 2208 | /* Seek to and update zip64 extension sizes */ |
| 2209 | if ((err == MZ_OKcxx . . $ `mz.h:21:9`!) && (zip64)) { |
| 2210 | int64_tcxx . . $ int64_t# filename_size = zip->file_infocxx . . $ mz_zip_s#file_info..filename_sizecxx . . $ mz_zip_file_s#filename_size.; |
| 2211 | |
| 2212 | if (filename_size == 0) |
| 2213 | filename_size = strlencxx . . $ strlen(751346f8406fd082).(zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename.); |
| 2214 | |
| 2215 | /* Since we write zip64 extension first we know its offset */ |
| 2216 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., 2 + 2 + filename_size + 4, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 2217 | |
| 2218 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2219 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(zip->streamcxx . . $ mz_zip_s#stream., zip->file_infocxx . . $ mz_zip_s#file_info..uncompressed_sizecxx . . $ mz_zip_file_s#uncompressed_size.); |
| 2220 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2221 | err = mz_stream_write_uint64cxx . . $ mz_stream_write_uint64(c0a5f96701d3f89).(zip->streamcxx . . $ mz_zip_s#stream., zip->file_infocxx . . $ mz_zip_s#file_info..compressed_sizecxx . . $ mz_zip_file_s#compressed_size.); |
| 2222 | } |
| 2223 | |
| 2224 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, end_disk_number); |
| 2225 | mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., end_pos, MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 2226 | } |
| 2227 | |
| 2228 | zip->number_entrycxx . . $ mz_zip_s#number_entry. += 1; |
| 2229 | |
| 2230 | mz_zip_entry_close_intcxx . . $ mz_zip_entry_close_int(dedf1e9b1c614a07).(handle); |
| 2231 | |
| 2232 | return err; |
| 2233 | } |
| 2234 | |
| 2235 | int32_tcxx . . $ int32_t# mz_zip_entry_seek_local_headercxx . . $ mz_zip_entry_seek_local_header(dedf1e9b1c614a07).(void *handle) { |
| 2236 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2237 | int64_tcxx . . $ int64_t# disk_size = 0; |
| 2238 | uint32_tcxx . . $ uint32_t# disk_number = zip->file_infocxx . . $ mz_zip_s#file_info..disk_numbercxx . . $ mz_zip_file_s#disk_number.; |
| 2239 | |
| 2240 | if (disk_number == zip->disk_number_with_cdcxx . . $ mz_zip_s#disk_number_with_cd.) { |
| 2241 | mz_stream_get_prop_int64cxx . . $ mz_stream_get_prop_int64(280df70541557ec8).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_SIZEcxx . . $ `mz_strm.h:26:9`!, &disk_size); |
| 2242 | if ((disk_size == 0) || ((zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) == 0)) |
| 2243 | disk_number = (uint32_tcxx . . $ uint32_t#)-1; |
| 2244 | } |
| 2245 | |
| 2246 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->streamcxx . . $ mz_zip_s#stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, disk_number); |
| 2247 | |
| 2248 | mz_zip_printcxx . . $ `mz_zip.c:125:11`!("Zip - Entry - Seek local (disk %" PRId32 " offset %" PRId64 ")\n", disk_number, |
| 2249 | zip->file_info.disk_offset); |
| 2250 | |
| 2251 | /* Guard against seek overflows */ |
| 2252 | if ((zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift. > 0) && (zip->file_infocxx . . $ mz_zip_s#file_info..disk_offsetcxx . . $ mz_zip_file_s#disk_offset. > (INT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:113:10`! - zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift.))) |
| 2253 | return MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 2254 | |
| 2255 | return mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->streamcxx . . $ mz_zip_s#stream., zip->file_infocxx . . $ mz_zip_s#file_info..disk_offsetcxx . . $ mz_zip_file_s#disk_offset. + zip->disk_offset_shiftcxx . . $ mz_zip_s#disk_offset_shift., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 2256 | } |
| 2257 | |
| 2258 | int32_tcxx . . $ int32_t# mz_zip_entry_get_compress_streamcxx . . $ mz_zip_entry_get_compress_stream(1843ed636859e0d0).(void *handle, void **compress_stream) { |
| 2259 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2260 | if (!zip || !compress_stream) |
| 2261 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2262 | *compress_stream = zip->compress_streamcxx . . $ mz_zip_s#compress_stream.; |
| 2263 | if (!*compress_stream) |
| 2264 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2265 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2266 | } |
| 2267 | |
| 2268 | int32_tcxx . . $ int32_t# mz_zip_entry_closecxx . . $ mz_zip_entry_close(dedf1e9b1c614a07).(void *handle) { |
| 2269 | return mz_zip_entry_close_rawcxx . . $ mz_zip_entry_close_raw(85007a28ff75c5e5).(handle, UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:119:10`!, 0); |
| 2270 | } |
| 2271 | |
| 2272 | int32_tcxx . . $ int32_t# mz_zip_entry_close_rawcxx . . $ mz_zip_entry_close_raw(85007a28ff75c5e5).(void *handle, int64_tcxx . . $ int64_t# uncompressed_size, uint32_tcxx . . $ uint32_t# crc32) { |
| 2273 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2274 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2275 | |
| 2276 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2277 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2278 | |
| 2279 | if (zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) |
| 2280 | err = mz_zip_entry_write_closecxx . . $ mz_zip_entry_write_close(b4f223597101ed9a).(handle, crc32, UINT64_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:119:10`!, uncompressed_size); |
| 2281 | else |
| 2282 | err = mz_zip_entry_read_closecxx . . $ mz_zip_entry_read_close(f358a56cc8c9350).(handle, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!, NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 2283 | |
| 2284 | return err; |
| 2285 | } |
| 2286 | |
| 2287 | int32_tcxx . . $ int32_t# mz_zip_entry_is_dircxx . . $ mz_zip_entry_is_dir(dedf1e9b1c614a07).(void *handle) { |
| 2288 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2289 | int32_tcxx . . $ int32_t# filename_length = 0; |
| 2290 | |
| 2291 | if (!zip || !zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned.) |
| 2292 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2293 | if (mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(zip->file_infocxx . . $ mz_zip_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., zip->file_infocxx . . $ mz_zip_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2294 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2295 | |
| 2296 | filename_length = (int32_tcxx . . $ int32_t#)strlencxx . . $ strlen(751346f8406fd082).(zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename.); |
| 2297 | if (filename_length > 0) { |
| 2298 | if (mz_os_is_dir_separatorcxx . . $ mz_os_is_dir_separator(784f3405e7e545be).(zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename.[filename_length - 1])) |
| 2299 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2300 | } |
| 2301 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2302 | } |
| 2303 | |
| 2304 | int32_tcxx . . $ int32_t# mz_zip_entry_is_symlinkcxx . . $ mz_zip_entry_is_symlink(dedf1e9b1c614a07).(void *handle) { |
| 2305 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2306 | |
| 2307 | if (!zip || !zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned.) |
| 2308 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2309 | if (mz_zip_attrib_is_symlinkcxx . . $ mz_zip_attrib_is_symlink(1cb9ad283036edc7).(zip->file_infocxx . . $ mz_zip_s#file_info..external_facxx . . $ mz_zip_file_s#external_fa., zip->file_infocxx . . $ mz_zip_s#file_info..version_madebycxx . . $ mz_zip_file_s#version_madeby.) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2310 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2311 | |
| 2312 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2313 | } |
| 2314 | |
| 2315 | int32_tcxx . . $ int32_t# mz_zip_entry_get_infocxx . . $ mz_zip_entry_get_info(4dd5ee9bdbc1d978).(void *handle, mz_zip_filecxx . . $ mz_zip_file# **file_info) { |
| 2316 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2317 | |
| 2318 | if (!zip) |
| 2319 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2320 | |
| 2321 | if ((zip->open_modecxx . . $ mz_zip_s#open_mode. & MZ_OPEN_MODE_WRITEcxx . . $ `mz.h:51:9`!) == 0) { |
| 2322 | if (!zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned.) |
| 2323 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2324 | } |
| 2325 | |
| 2326 | *file_info = &zip->file_infocxx . . $ mz_zip_s#file_info.; |
| 2327 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2328 | } |
| 2329 | |
| 2330 | int32_tcxx . . $ int32_t# mz_zip_entry_get_local_infocxx . . $ mz_zip_entry_get_local_info(4dd5ee9bdbc1d978).(void *handle, mz_zip_filecxx . . $ mz_zip_file# **local_file_info) { |
| 2331 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2332 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2333 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2334 | *local_file_info = &zip->local_file_infocxx . . $ mz_zip_s#local_file_info.; |
| 2335 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2336 | } |
| 2337 | |
| 2338 | int32_tcxx . . $ int32_t# mz_zip_entry_set_extrafieldcxx . . $ mz_zip_entry_set_extrafield(1048ced145d6ae0d).(void *handle, const uint8_tcxx . . $ uint8_t# *extrafield, uint16_tcxx . . $ uint16_t# extrafield_size) { |
| 2339 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2340 | |
| 2341 | if (!zip || mz_zip_entry_is_opencxx . . $ mz_zip_entry_is_open(dedf1e9b1c614a07).(handle) != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2342 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2343 | |
| 2344 | zip->file_infocxx . . $ mz_zip_s#file_info..extrafieldcxx . . $ mz_zip_file_s#extrafield. = extrafield; |
| 2345 | zip->file_infocxx . . $ mz_zip_s#file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. = extrafield_size; |
| 2346 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2347 | } |
| 2348 | |
| 2349 | static int32_tcxx . . $ int32_t# mz_zip_goto_next_entry_intcxx . . $ mz_zip_goto_next_entry_int(dedf1e9b1c614a07).(void *handle) { |
| 2350 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2351 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2352 | |
| 2353 | if (!zip) |
| 2354 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2355 | |
| 2356 | zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned. = 0; |
| 2357 | |
| 2358 | mz_stream_set_prop_int64cxx . . $ mz_stream_set_prop_int64(5f4b2ff0df22ef2b).(zip->cd_streamcxx . . $ mz_zip_s#cd_stream., MZ_STREAM_PROP_DISK_NUMBERcxx . . $ `mz_strm.h:27:9`!, -1); |
| 2359 | |
| 2360 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(zip->cd_streamcxx . . $ mz_zip_s#cd_stream., zip->cd_current_poscxx . . $ mz_zip_s#cd_current_pos., MZ_SEEK_SETcxx . . $ `mz.h:58:9`!); |
| 2361 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2362 | err = mz_zip_entry_read_headercxx . . $ mz_zip_entry_read_header(22e9f4de044eb2c0).(zip->cd_streamcxx . . $ mz_zip_s#cd_stream., 0, &zip->file_infocxx . . $ mz_zip_s#file_info., zip->file_info_streamcxx . . $ mz_zip_s#file_info_stream.); |
| 2363 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2364 | zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned. = 1; |
| 2365 | return err; |
| 2366 | } |
| 2367 | |
| 2368 | int64_tcxx . . $ int64_t# mz_zip_get_entrycxx . . $ mz_zip_get_entry(72c1818a5177f981).(void *handle) { |
| 2369 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2370 | |
| 2371 | if (!zip) |
| 2372 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2373 | |
| 2374 | return zip->cd_current_poscxx . . $ mz_zip_s#cd_current_pos.; |
| 2375 | } |
| 2376 | |
| 2377 | int32_tcxx . . $ int32_t# mz_zip_goto_entrycxx . . $ mz_zip_goto_entry(6b20ed9d0f5b4b14).(void *handle, int64_tcxx . . $ int64_t# cd_pos) { |
| 2378 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2379 | |
| 2380 | if (!zip) |
| 2381 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2382 | |
| 2383 | if (cd_pos < zip->cd_start_poscxx . . $ mz_zip_s#cd_start_pos. || cd_pos > zip->cd_start_poscxx . . $ mz_zip_s#cd_start_pos. + zip->cd_sizecxx . . $ mz_zip_s#cd_size.) |
| 2384 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2385 | |
| 2386 | zip->cd_current_poscxx . . $ mz_zip_s#cd_current_pos. = cd_pos; |
| 2387 | |
| 2388 | return mz_zip_goto_next_entry_intcxx . . $ mz_zip_goto_next_entry_int(dedf1e9b1c614a07).(handle); |
| 2389 | } |
| 2390 | |
| 2391 | int32_tcxx . . $ int32_t# mz_zip_goto_first_entrycxx . . $ mz_zip_goto_first_entry(dedf1e9b1c614a07).(void *handle) { |
| 2392 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2393 | |
| 2394 | if (!zip) |
| 2395 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2396 | |
| 2397 | zip->cd_current_poscxx . . $ mz_zip_s#cd_current_pos. = zip->cd_start_poscxx . . $ mz_zip_s#cd_start_pos.; |
| 2398 | |
| 2399 | return mz_zip_goto_next_entry_intcxx . . $ mz_zip_goto_next_entry_int(dedf1e9b1c614a07).(handle); |
| 2400 | } |
| 2401 | |
| 2402 | int32_tcxx . . $ int32_t# mz_zip_goto_next_entrycxx . . $ mz_zip_goto_next_entry(dedf1e9b1c614a07).(void *handle) { |
| 2403 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2404 | |
| 2405 | if (!zip) |
| 2406 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2407 | |
| 2408 | zip->cd_current_poscxx . . $ mz_zip_s#cd_current_pos. += (int64_tcxx . . $ int64_t#)MZ_ZIP_SIZE_CD_ITEMcxx . . $ `mz_zip.c:71:9`! + zip->file_infocxx . . $ mz_zip_s#file_info..filename_sizecxx . . $ mz_zip_file_s#filename_size. + |
| 2409 | zip->file_infocxx . . $ mz_zip_s#file_info..extrafield_sizecxx . . $ mz_zip_file_s#extrafield_size. + zip->file_infocxx . . $ mz_zip_s#file_info..comment_sizecxx . . $ mz_zip_file_s#comment_size.; |
| 2410 | |
| 2411 | return mz_zip_goto_next_entry_intcxx . . $ mz_zip_goto_next_entry_int(dedf1e9b1c614a07).(handle); |
| 2412 | } |
| 2413 | |
| 2414 | int32_tcxx . . $ int32_t# mz_zip_locate_entrycxx . . $ mz_zip_locate_entry(e99e7bb7a9acb132).(void *handle, const char *filename, uint8_tcxx . . $ uint8_t# ignore_case) { |
| 2415 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2416 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2417 | int32_tcxx . . $ int32_t# result = 0; |
| 2418 | |
| 2419 | if (!zip || !filename) |
| 2420 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2421 | |
| 2422 | /* If we are already on the current entry, no need to search */ |
| 2423 | if (zip->entry_scannedcxx . . $ mz_zip_s#entry_scanned. && zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename.) { |
| 2424 | result = mz_zip_path_comparecxx . . $ mz_zip_path_compare(6dbe66b8d729cbab).(zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename., filename, ignore_case); |
| 2425 | if (result == 0) |
| 2426 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2427 | } |
| 2428 | |
| 2429 | /* Search all entries starting at the first */ |
| 2430 | err = mz_zip_goto_first_entrycxx . . $ mz_zip_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 2431 | while (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2432 | result = mz_zip_path_comparecxx . . $ mz_zip_path_compare(6dbe66b8d729cbab).(zip->file_infocxx . . $ mz_zip_s#file_info..filenamecxx . . $ mz_zip_file_s#filename., filename, ignore_case); |
| 2433 | if (result == 0) |
| 2434 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2435 | |
| 2436 | err = mz_zip_goto_next_entrycxx . . $ mz_zip_goto_next_entry(dedf1e9b1c614a07).(handle); |
| 2437 | } |
| 2438 | |
| 2439 | return err; |
| 2440 | } |
| 2441 | |
| 2442 | int32_tcxx . . $ int32_t# mz_zip_locate_first_entrycxx . . $ mz_zip_locate_first_entry(ecab7b9312e6e1a9).(void *handle, void *userdata, mz_zip_locate_entry_cbcxx . . $ mz_zip_locate_entry_cb# cb) { |
| 2443 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2444 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2445 | int32_tcxx . . $ int32_t# result = 0; |
| 2446 | |
| 2447 | /* Search first entry looking for match */ |
| 2448 | err = mz_zip_goto_first_entrycxx . . $ mz_zip_goto_first_entry(dedf1e9b1c614a07).(handle); |
| 2449 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2450 | return err; |
| 2451 | |
| 2452 | result = cb(handle, userdata, &zip->file_infocxx . . $ mz_zip_s#file_info.); |
| 2453 | if (result == 0) |
| 2454 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2455 | |
| 2456 | return mz_zip_locate_next_entrycxx . . $ mz_zip_locate_next_entry(ecab7b9312e6e1a9).(handle, userdata, cb); |
| 2457 | } |
| 2458 | |
| 2459 | int32_tcxx . . $ int32_t# mz_zip_locate_next_entrycxx . . $ mz_zip_locate_next_entry(ecab7b9312e6e1a9).(void *handle, void *userdata, mz_zip_locate_entry_cbcxx . . $ mz_zip_locate_entry_cb# cb) { |
| 2460 | mz_zipcxx . . $ mz_zip# *zip = (mz_zipcxx . . $ mz_zip# *)handle; |
| 2461 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2462 | int32_tcxx . . $ int32_t# result = 0; |
| 2463 | |
| 2464 | /* Search next entries looking for match */ |
| 2465 | err = mz_zip_goto_next_entrycxx . . $ mz_zip_goto_next_entry(dedf1e9b1c614a07).(handle); |
| 2466 | while (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2467 | result = cb(handle, userdata, &zip->file_infocxx . . $ mz_zip_s#file_info.); |
| 2468 | if (result == 0) |
| 2469 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2470 | |
| 2471 | err = mz_zip_goto_next_entrycxx . . $ mz_zip_goto_next_entry(dedf1e9b1c614a07).(handle); |
| 2472 | } |
| 2473 | |
| 2474 | return err; |
| 2475 | } |
| 2476 | |
| 2477 | /***************************************************************************/ |
| 2478 | |
| 2479 | int32_tcxx . . $ int32_t# mz_zip_attrib_is_dircxx . . $ mz_zip_attrib_is_dir(1cb9ad283036edc7).(uint32_tcxx . . $ uint32_t# attrib, int32_tcxx . . $ int32_t# version_madeby) { |
| 2480 | uint32_tcxx . . $ uint32_t# posix_attrib = 0; |
| 2481 | uint8_tcxx . . $ uint8_t# system = MZ_HOST_SYSTEMcxx . . $ `mz.h:102:9`!(version_madeby); |
| 2482 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2483 | |
| 2484 | err = mz_zip_attrib_convertcxx . . $ mz_zip_attrib_convert(20c6f379b34f0b73).(system, attrib, MZ_HOST_SYSTEM_UNIXcxx . . $ `mz.h:104:9`!, &posix_attrib); |
| 2485 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2486 | if ((posix_attrib & 0170000) == 0040000) /* S_ISDIR */ |
| 2487 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2488 | } |
| 2489 | |
| 2490 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2491 | } |
| 2492 | |
| 2493 | int32_tcxx . . $ int32_t# mz_zip_attrib_is_symlinkcxx . . $ mz_zip_attrib_is_symlink(1cb9ad283036edc7).(uint32_tcxx . . $ uint32_t# attrib, int32_tcxx . . $ int32_t# version_madeby) { |
| 2494 | uint32_tcxx . . $ uint32_t# posix_attrib = 0; |
| 2495 | uint8_tcxx . . $ uint8_t# system = MZ_HOST_SYSTEMcxx . . $ `mz.h:102:9`!(version_madeby); |
| 2496 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2497 | |
| 2498 | err = mz_zip_attrib_convertcxx . . $ mz_zip_attrib_convert(20c6f379b34f0b73).(system, attrib, MZ_HOST_SYSTEM_UNIXcxx . . $ `mz.h:104:9`!, &posix_attrib); |
| 2499 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) { |
| 2500 | if ((posix_attrib & 0170000) == 0120000) /* S_ISLNK */ |
| 2501 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2502 | } |
| 2503 | |
| 2504 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2505 | } |
| 2506 | |
| 2507 | int32_tcxx . . $ int32_t# mz_zip_attrib_convertcxx . . $ mz_zip_attrib_convert(20c6f379b34f0b73).(uint8_tcxx . . $ uint8_t# src_sys, uint32_tcxx . . $ uint32_t# src_attrib, uint8_tcxx . . $ uint8_t# target_sys, uint32_tcxx . . $ uint32_t# *target_attrib) { |
| 2508 | if (!target_attrib) |
| 2509 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2510 | |
| 2511 | *target_attrib = 0; |
| 2512 | |
| 2513 | if ((src_sys == MZ_HOST_SYSTEM_MSDOScxx . . $ `mz.h:103:9`!) || (src_sys == MZ_HOST_SYSTEM_WINDOWS_NTFScxx . . $ `mz.h:105:9`!)) { |
| 2514 | if ((target_sys == MZ_HOST_SYSTEM_MSDOScxx . . $ `mz.h:103:9`!) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFScxx . . $ `mz.h:105:9`!)) { |
| 2515 | *target_attrib = src_attrib; |
| 2516 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2517 | } |
| 2518 | if ((target_sys == MZ_HOST_SYSTEM_UNIXcxx . . $ `mz.h:104:9`!) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWINcxx . . $ `mz.h:107:9`!) || |
| 2519 | (target_sys == MZ_HOST_SYSTEM_RISCOScxx . . $ `mz.h:106:9`!)) |
| 2520 | return mz_zip_attrib_win32_to_posixcxx . . $ mz_zip_attrib_win32_to_posix(7f1e8d1214e46d8c).(src_attrib, target_attrib); |
| 2521 | } else if ((src_sys == MZ_HOST_SYSTEM_UNIXcxx . . $ `mz.h:104:9`!) || (src_sys == MZ_HOST_SYSTEM_OSX_DARWINcxx . . $ `mz.h:107:9`!) || |
| 2522 | (src_sys == MZ_HOST_SYSTEM_RISCOScxx . . $ `mz.h:106:9`!)) { |
| 2523 | /* If high bytes are set, it contains unix specific attributes */ |
| 2524 | if ((src_attrib >> 16) != 0) |
| 2525 | src_attrib >>= 16; |
| 2526 | |
| 2527 | if ((target_sys == MZ_HOST_SYSTEM_UNIXcxx . . $ `mz.h:104:9`!) || (target_sys == MZ_HOST_SYSTEM_OSX_DARWINcxx . . $ `mz.h:107:9`!) || |
| 2528 | (target_sys == MZ_HOST_SYSTEM_RISCOScxx . . $ `mz.h:106:9`!)) { |
| 2529 | *target_attrib = src_attrib; |
| 2530 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2531 | } |
| 2532 | if ((target_sys == MZ_HOST_SYSTEM_MSDOScxx . . $ `mz.h:103:9`!) || (target_sys == MZ_HOST_SYSTEM_WINDOWS_NTFScxx . . $ `mz.h:105:9`!)) |
| 2533 | return mz_zip_attrib_posix_to_win32cxx . . $ mz_zip_attrib_posix_to_win32(7f1e8d1214e46d8c).(src_attrib, target_attrib); |
| 2534 | } |
| 2535 | |
| 2536 | return MZ_SUPPORT_ERRORcxx . . $ `mz.h:38:9`!; |
| 2537 | } |
| 2538 | |
| 2539 | int32_tcxx . . $ int32_t# mz_zip_attrib_posix_to_win32cxx . . $ mz_zip_attrib_posix_to_win32(7f1e8d1214e46d8c).(uint32_tcxx . . $ uint32_t# posix_attrib, uint32_tcxx . . $ uint32_t# *win32_attrib) { |
| 2540 | if (!win32_attrib) |
| 2541 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2542 | |
| 2543 | *win32_attrib = 0; |
| 2544 | |
| 2545 | /* S_IWUSR | S_IWGRP | S_IWOTH | S_IXUSR | S_IXGRP | S_IXOTH */ |
| 2546 | if ((posix_attrib & 0000333) == 0 && (posix_attrib & 0000444) != 0) |
| 2547 | *win32_attrib |= 0x01; /* FILE_ATTRIBUTE_READONLY */ |
| 2548 | /* S_IFLNK */ |
| 2549 | if ((posix_attrib & 0170000) == 0120000) |
| 2550 | *win32_attrib |= 0x400; /* FILE_ATTRIBUTE_REPARSE_POINT */ |
| 2551 | /* S_IFDIR */ |
| 2552 | else if ((posix_attrib & 0170000) == 0040000) |
| 2553 | *win32_attrib |= 0x10; /* FILE_ATTRIBUTE_DIRECTORY */ |
| 2554 | /* S_IFREG */ |
| 2555 | else |
| 2556 | *win32_attrib |= 0x80; /* FILE_ATTRIBUTE_NORMAL */ |
| 2557 | |
| 2558 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2559 | } |
| 2560 | |
| 2561 | int32_tcxx . . $ int32_t# mz_zip_attrib_win32_to_posixcxx . . $ mz_zip_attrib_win32_to_posix(7f1e8d1214e46d8c).(uint32_tcxx . . $ uint32_t# win32_attrib, uint32_tcxx . . $ uint32_t# *posix_attrib) { |
| 2562 | if (!posix_attrib) |
| 2563 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2564 | |
| 2565 | *posix_attrib = 0000444; /* S_IRUSR | S_IRGRP | S_IROTH */ |
| 2566 | /* FILE_ATTRIBUTE_READONLY */ |
| 2567 | if ((win32_attrib & 0x01) == 0) |
| 2568 | *posix_attrib |= 0000222; /* S_IWUSR | S_IWGRP | S_IWOTH */ |
| 2569 | /* FILE_ATTRIBUTE_REPARSE_POINT */ |
| 2570 | if ((win32_attrib & 0x400) == 0x400) |
| 2571 | *posix_attrib |= 0120000; /* S_IFLNK */ |
| 2572 | /* FILE_ATTRIBUTE_DIRECTORY */ |
| 2573 | else if ((win32_attrib & 0x10) == 0x10) |
| 2574 | *posix_attrib |= 0040111; /* S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH */ |
| 2575 | else |
| 2576 | *posix_attrib |= 0100000; /* S_IFREG */ |
| 2577 | |
| 2578 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2579 | } |
| 2580 | |
| 2581 | /***************************************************************************/ |
| 2582 | |
| 2583 | int32_tcxx . . $ int32_t# mz_zip_extrafield_findcxx . . $ mz_zip_extrafield_find(70fe6fe7767d52f0).(void *stream, uint16_tcxx . . $ uint16_t# type, int32_tcxx . . $ int32_t# max_seek, uint16_tcxx . . $ uint16_t# *length) { |
| 2584 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2585 | uint16_tcxx . . $ uint16_t# field_type = 0; |
| 2586 | uint16_tcxx . . $ uint16_t# field_length = 0; |
| 2587 | |
| 2588 | if (max_seek < 4) |
| 2589 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2590 | |
| 2591 | do { |
| 2592 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &field_type); |
| 2593 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2594 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, &field_length); |
| 2595 | if (err != MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2596 | break; |
| 2597 | |
| 2598 | if (type == field_type) { |
| 2599 | if (length) |
| 2600 | *length = field_length; |
| 2601 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2602 | } |
| 2603 | |
| 2604 | max_seek -= field_length - 4; |
| 2605 | if (max_seek < 0) |
| 2606 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2607 | |
| 2608 | err = mz_stream_seekcxx . . $ mz_stream_seek(8bc0ff128761c75d).(stream, field_length, MZ_SEEK_CURcxx . . $ `mz.h:59:9`!); |
| 2609 | } while (err == MZ_OKcxx . . $ `mz.h:21:9`!); |
| 2610 | |
| 2611 | return MZ_EXIST_ERRORcxx . . $ `mz.h:36:9`!; |
| 2612 | } |
| 2613 | |
| 2614 | int32_tcxx . . $ int32_t# mz_zip_extrafield_containscxx . . $ mz_zip_extrafield_contains(b9c376550f650e).(const uint8_tcxx . . $ uint8_t# *extrafield, int32_tcxx . . $ int32_t# extrafield_size, uint16_tcxx . . $ uint16_t# type, |
| 2615 | uint16_tcxx . . $ uint16_t# *length) { |
| 2616 | void *file_extra_stream = NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!; |
| 2617 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2618 | |
| 2619 | if (!extrafield || !extrafield_size) |
| 2620 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2621 | |
| 2622 | file_extra_stream = mz_stream_mem_createcxx . . $ mz_stream_mem_create(50c7df7de5344ebb).(); |
| 2623 | if (!file_extra_stream) |
| 2624 | return MZ_MEM_ERRORcxx . . $ `mz.h:24:9`!; |
| 2625 | |
| 2626 | mz_stream_mem_set_buffercxx . . $ mz_stream_mem_set_buffer(5be095a8278d2bf5).(file_extra_stream, (void *)extrafield, extrafield_size); |
| 2627 | err = mz_zip_extrafield_findcxx . . $ mz_zip_extrafield_find(70fe6fe7767d52f0).(file_extra_stream, type, extrafield_size, length); |
| 2628 | mz_stream_mem_deletecxx . . $ mz_stream_mem_delete(539e082cf00e1f43).(&file_extra_stream); |
| 2629 | return err; |
| 2630 | } |
| 2631 | |
| 2632 | int32_tcxx . . $ int32_t# mz_zip_extrafield_readcxx . . $ mz_zip_extrafield_read(9a4a45287d8af1f7).(void *stream, uint16_tcxx . . $ uint16_t# *type, uint16_tcxx . . $ uint16_t# *length) { |
| 2633 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2634 | if (!type || !length) |
| 2635 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2636 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, type); |
| 2637 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2638 | err = mz_stream_read_uint16cxx . . $ mz_stream_read_uint16(900c00eb402c9863).(stream, length); |
| 2639 | return err; |
| 2640 | } |
| 2641 | |
| 2642 | int32_tcxx . . $ int32_t# mz_zip_extrafield_writecxx . . $ mz_zip_extrafield_write(687657bf8ffaf397).(void *stream, uint16_tcxx . . $ uint16_t# type, uint16_tcxx . . $ uint16_t# length) { |
| 2643 | int32_tcxx . . $ int32_t# err = MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2644 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, type); |
| 2645 | if (err == MZ_OKcxx . . $ `mz.h:21:9`!) |
| 2646 | err = mz_stream_write_uint16cxx . . $ mz_stream_write_uint16(f805ef7ae580f896).(stream, length); |
| 2647 | return err; |
| 2648 | } |
| 2649 | |
| 2650 | /***************************************************************************/ |
| 2651 | |
| 2652 | static int32_tcxx . . $ int32_t# mz_zip_invalid_datecxx . . $ mz_zip_invalid_date(6215ee0d117e595a).(const struct tmcxx . . $ tm# *ptm) { |
| 2653 | #define datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(min, max, value) ((min) <= (value) && (value) <= (max)) |
| 2654 | return (!datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(0, 127 + 80, ptm->tm_year) || /* 1980-based year, allow 80 extra */ |
| 2655 | !datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(0, 11, ptm->tm_mon) || !datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(1, 31, ptm->tm_mday) || |
| 2656 | !datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(0, 23, ptm->tm_hour) || !datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(0, 59, ptm->tm_min) || |
| 2657 | !datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`!(0, 59, ptm->tm_sec)); |
| 2658 | #undef datevalue_in_rangecxx . . $ `mz_zip.c:2653:9`! |
| 2659 | } |
| 2660 | |
| 2661 | static void mz_zip_dosdate_to_raw_tmcxx . . $ mz_zip_dosdate_to_raw_tm(16acd81856f16c54).(uint64_tcxx . . $ uint64_t# dos_date, struct tmcxx . . $ tm# *ptm) { |
| 2662 | uint64_tcxx . . $ uint64_t# date = (uint64_tcxx . . $ uint64_t#)(dos_date >> 16); |
| 2663 | |
| 2664 | ptm->tm_mdaycxx . . $ tm#tm_mday. = (int16_tcxx . . $ int16_t#)(date & 0x1f); |
| 2665 | ptm->tm_moncxx . . $ tm#tm_mon. = (int16_tcxx . . $ int16_t#)(((date & 0x1E0) / 0x20) - 1); |
| 2666 | ptm->tm_yearcxx . . $ tm#tm_year. = (int16_tcxx . . $ int16_t#)(((date & 0x0FE00) / 0x0200) + 80); |
| 2667 | ptm->tm_hourcxx . . $ tm#tm_hour. = (int16_tcxx . . $ int16_t#)((dos_date & 0xF800) / 0x800); |
| 2668 | ptm->tm_mincxx . . $ tm#tm_min. = (int16_tcxx . . $ int16_t#)((dos_date & 0x7E0) / 0x20); |
| 2669 | ptm->tm_seccxx . . $ tm#tm_sec. = (int16_tcxx . . $ int16_t#)(2 * (dos_date & 0x1f)); |
| 2670 | ptm->tm_isdstcxx . . $ tm#tm_isdst. = -1; |
| 2671 | } |
| 2672 | |
| 2673 | int32_tcxx . . $ int32_t# mz_zip_dosdate_to_tmcxx . . $ mz_zip_dosdate_to_tm(3b58ac8b5d78a0e1).(uint64_tcxx . . $ uint64_t# dos_date, struct tmcxx . . $ tm# *ptm) { |
| 2674 | if (!ptm) |
| 2675 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2676 | |
| 2677 | mz_zip_dosdate_to_raw_tmcxx . . $ mz_zip_dosdate_to_raw_tm(16acd81856f16c54).(dos_date, ptm); |
| 2678 | |
| 2679 | if (mz_zip_invalid_datecxx . . $ mz_zip_invalid_date(6215ee0d117e595a).(ptm)) { |
| 2680 | /* Invalid date stored, so don't return it */ |
| 2681 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ptm, 0, sizeof(struct tmcxx . . $ tm#)); |
| 2682 | return MZ_FORMAT_ERRORcxx . . $ `mz.h:32:9`!; |
| 2683 | } |
| 2684 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2685 | } |
| 2686 | |
| 2687 | time_tcxx . . $ time_t# mz_zip_dosdate_to_time_tcxx . . $ mz_zip_dosdate_to_time_t(f7e21917e59627ec).(uint64_tcxx . . $ uint64_t# dos_date) { |
| 2688 | struct tmcxx . . $ tm# ptm; |
| 2689 | mz_zip_dosdate_to_raw_tmcxx . . $ mz_zip_dosdate_to_raw_tm(16acd81856f16c54).(dos_date, &ptm); |
| 2690 | return mz_zip_tm_to_time_tcxx . . $ mz_zip_tm_to_time_t(237c3516b2cfac2c).(&ptm); |
| 2691 | } |
| 2692 | |
| 2693 | time_tcxx . . $ time_t# mz_zip_tm_to_time_tcxx . . $ mz_zip_tm_to_time_t(237c3516b2cfac2c).(struct tmcxx . . $ tm# *ptm) { |
| 2694 | return mktimecxx . . $ mktime(237c3516b2cfac2c).(ptm); |
| 2695 | } |
| 2696 | |
| 2697 | int32_tcxx . . $ int32_t# mz_zip_time_t_to_tmcxx . . $ mz_zip_time_t_to_tm(ec51dbf3953610a8).(time_tcxx . . $ time_t# unix_time, struct tmcxx . . $ tm# *ptm) { |
| 2698 | struct tmcxx . . $ tm# ltm; |
| 2699 | if (!ptm) |
| 2700 | return MZ_PARAM_ERRORcxx . . $ `mz.h:31:9`!; |
| 2701 | if (!localtime_rcxx . . $ localtime_r(92e3d173686db852).(&unix_time, <m)) { /* Returns a 1900-based year */ |
| 2702 | /* Invalid date stored, so don't return it */ |
| 2703 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(ptm, 0, sizeof(struct tmcxx . . $ tm#)); |
| 2704 | return MZ_INTERNAL_ERRORcxx . . $ `mz.h:33:9`!; |
| 2705 | } |
| 2706 | memcpycxx . . $ memcpy(cc817cb175f282d).(ptm, <m, sizeof(struct tmcxx . . $ tm#)); |
| 2707 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2708 | } |
| 2709 | |
| 2710 | uint32_tcxx . . $ uint32_t# mz_zip_time_t_to_dos_datecxx . . $ mz_zip_time_t_to_dos_date(bd267e0bd5a0c68b).(time_tcxx . . $ time_t# unix_time) { |
| 2711 | struct tmcxx . . $ tm# ptm; |
| 2712 | mz_zip_time_t_to_tmcxx . . $ mz_zip_time_t_to_tm(ec51dbf3953610a8).(unix_time, &ptm); |
| 2713 | return mz_zip_tm_to_dosdatecxx . . $ mz_zip_tm_to_dosdate(480364279e353dd5).((const struct tmcxx . . $ tm# *)&ptm); |
| 2714 | } |
| 2715 | |
| 2716 | uint32_tcxx . . $ uint32_t# mz_zip_tm_to_dosdatecxx . . $ mz_zip_tm_to_dosdate(480364279e353dd5).(const struct tmcxx . . $ tm# *ptm) { |
| 2717 | struct tmcxx . . $ tm# fixed_tm; |
| 2718 | |
| 2719 | /* Years supported: */ |
| 2720 | |
| 2721 | /* [00, 79] (assumed to be between 2000 and 2079) */ |
| 2722 | /* [80, 207] (assumed to be between 1980 and 2107, typical output of old */ |
| 2723 | /* software that does 'year-1900' to get a double digit year) */ |
| 2724 | /* [1980, 2107] (due to format limitations, only years 1980-2107 can be stored.) */ |
| 2725 | |
| 2726 | memcpycxx . . $ memcpy(cc817cb175f282d).(&fixed_tm, ptm, sizeof(struct tmcxx . . $ tm#)); |
| 2727 | if (fixed_tm.tm_yearcxx . . $ tm#tm_year. >= 1980) /* range [1980, 2107] */ |
| 2728 | fixed_tm.tm_yearcxx . . $ tm#tm_year. -= 1980; |
| 2729 | else if (fixed_tm.tm_yearcxx . . $ tm#tm_year. >= 80) /* range [80, 207] */ |
| 2730 | fixed_tm.tm_yearcxx . . $ tm#tm_year. -= 80; |
| 2731 | else /* range [00, 79] */ |
| 2732 | fixed_tm.tm_yearcxx . . $ tm#tm_year. += 20; |
| 2733 | |
| 2734 | if (mz_zip_invalid_datecxx . . $ mz_zip_invalid_date(6215ee0d117e595a).(&fixed_tm)) |
| 2735 | return 0; |
| 2736 | |
| 2737 | return (((uint32_tcxx . . $ uint32_t#)fixed_tm.tm_mdaycxx . . $ tm#tm_mday. + (32 * ((uint32_tcxx . . $ uint32_t#)fixed_tm.tm_moncxx . . $ tm#tm_mon. + 1)) + (512 * (uint32_tcxx . . $ uint32_t#)fixed_tm.tm_yearcxx . . $ tm#tm_year.)) |
| 2738 | << 16) | |
| 2739 | (((uint32_tcxx . . $ uint32_t#)fixed_tm.tm_seccxx . . $ tm#tm_sec. / 2) + (32 * (uint32_tcxx . . $ uint32_t#)fixed_tm.tm_mincxx . . $ tm#tm_min.) + (2048 * (uint32_tcxx . . $ uint32_t#)fixed_tm.tm_hourcxx . . $ tm#tm_hour.)); |
| 2740 | } |
| 2741 | |
| 2742 | int32_tcxx . . $ int32_t# mz_zip_ntfs_to_unix_timecxx . . $ mz_zip_ntfs_to_unix_time(c11a4b583e983ba5).(uint64_tcxx . . $ uint64_t# ntfs_time, time_tcxx . . $ time_t# *unix_time) { |
| 2743 | *unix_time = (time_tcxx . . $ time_t#)((ntfs_time - 116444736000000000LL) / 10000000); |
| 2744 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2745 | } |
| 2746 | |
| 2747 | int32_tcxx . . $ int32_t# mz_zip_unix_to_ntfs_timecxx . . $ mz_zip_unix_to_ntfs_time(a0529548657e71e7).(time_tcxx . . $ time_t# unix_time, uint64_tcxx . . $ uint64_t# *ntfs_time) { |
| 2748 | *ntfs_time = ((uint64_tcxx . . $ uint64_t#)unix_time * 10000000) + 116444736000000000LL; |
| 2749 | return MZ_OKcxx . . $ `mz.h:21:9`!; |
| 2750 | } |
| 2751 | |
| 2752 | /***************************************************************************/ |
| 2753 | |
| 2754 | int32_tcxx . . $ int32_t# mz_zip_path_comparecxx . . $ mz_zip_path_compare(6dbe66b8d729cbab).(const char *path1, const char *path2, uint8_tcxx . . $ uint8_t# ignore_case) { |
| 2755 | do { |
| 2756 | if ((*path1 == '\\' && *path2 == '/') || (*path2 == '\\' && *path1 == '/')) { |
| 2757 | /* Ignore comparison of path slashes */ |
| 2758 | } else if (ignore_case) { |
| 2759 | if (tolowercxx . . $ tolower(7864480464b09eea).(*path1) != tolowercxx . . $ tolower(7864480464b09eea).(*path2)) |
| 2760 | break; |
| 2761 | } else if (*path1 != *path2) { |
| 2762 | break; |
| 2763 | } |
| 2764 | |
| 2765 | path1 += 1; |
| 2766 | path2 += 1; |
| 2767 | } while (*path1 != 0 && *path2 != 0); |
| 2768 | |
| 2769 | if (ignore_case) |
| 2770 | return (int32_tcxx . . $ int32_t#)(tolowercxx . . $ tolower(7864480464b09eea).(*path1) - tolowercxx . . $ tolower(7864480464b09eea).(*path2)); |
| 2771 | |
| 2772 | return (int32_tcxx . . $ int32_t#)(*path1 - *path2); |
| 2773 | } |
| 2774 | |
| 2775 | /***************************************************************************/ |
| 2776 | |
| 2777 | const char *mz_zip_get_compression_method_stringcxx . . $ mz_zip_get_compression_method_string(f7ae7e56280f18ae).(int32_tcxx . . $ int32_t# compression_method) { |
| 2778 | const char *method = "?"; |
| 2779 | switch (compression_method) { |
| 2780 | case MZ_COMPRESS_METHOD_STOREcxx . . $ `mz.h:63:9`!: |
| 2781 | method = "stored"; |
| 2782 | break; |
| 2783 | case MZ_COMPRESS_METHOD_DEFLATEcxx . . $ `mz.h:64:9`!: |
| 2784 | method = "deflate"; |
| 2785 | break; |
| 2786 | case MZ_COMPRESS_METHOD_BZIP2cxx . . $ `mz.h:65:9`!: |
| 2787 | method = "bzip2"; |
| 2788 | break; |
| 2789 | case MZ_COMPRESS_METHOD_LZMAcxx . . $ `mz.h:66:9`!: |
| 2790 | method = "lzma"; |
| 2791 | break; |
| 2792 | case MZ_COMPRESS_METHOD_XZcxx . . $ `mz.h:68:9`!: |
| 2793 | method = "xz"; |
| 2794 | break; |
| 2795 | case MZ_COMPRESS_METHOD_ZSTDcxx . . $ `mz.h:67:9`!: |
| 2796 | method = "zstd"; |
| 2797 | break; |
| 2798 | } |
| 2799 | return method; |
| 2800 | } |
| 2801 | |
| 2802 | /***************************************************************************/ |