|
|
|
@@ -135,8 +135,13 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|
|
|
#define MZ_FCLOSE fclose
|
|
|
|
#define MZ_FCLOSE fclose
|
|
|
|
#define MZ_FREAD fread
|
|
|
|
#define MZ_FREAD fread
|
|
|
|
#define MZ_FWRITE fwrite
|
|
|
|
#define MZ_FWRITE fwrite
|
|
|
|
|
|
|
|
#ifdef __STRICT_ANSI__
|
|
|
|
|
|
|
|
#define MZ_FTELL64 ftell
|
|
|
|
|
|
|
|
#define MZ_FSEEK64 fseek
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define MZ_FTELL64 ftello
|
|
|
|
#define MZ_FTELL64 ftello
|
|
|
|
#define MZ_FSEEK64 fseeko
|
|
|
|
#define MZ_FSEEK64 fseeko
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#define MZ_FILE_STAT_STRUCT stat
|
|
|
|
#define MZ_FILE_STAT_STRUCT stat
|
|
|
|
#define MZ_FILE_STAT stat
|
|
|
|
#define MZ_FILE_STAT stat
|
|
|
|
#define MZ_FFLUSH fflush
|
|
|
|
#define MZ_FFLUSH fflush
|
|
|
|
@@ -150,13 +155,13 @@ static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
|
|
|
|
/* Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. */
|
|
|
|
/* Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff. */
|
|
|
|
enum
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* ZIP archive identifiers and record sizes */
|
|
|
|
/* ZIP archive identifiers and record sizes */
|
|
|
|
MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50,
|
|
|
|
MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50,
|
|
|
|
MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50,
|
|
|
|
MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50,
|
|
|
|
MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50,
|
|
|
|
MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50,
|
|
|
|
MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30,
|
|
|
|
MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30,
|
|
|
|
MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46,
|
|
|
|
MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46,
|
|
|
|
MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22,
|
|
|
|
MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22,
|
|
|
|
|
|
|
|
|
|
|
|
/* ZIP64 archive identifier and record sizes */
|
|
|
|
/* ZIP64 archive identifier and record sizes */
|
|
|
|
MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06064b50,
|
|
|
|
MZ_ZIP64_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06064b50,
|
|
|
|
@@ -165,8 +170,8 @@ enum
|
|
|
|
MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE = 20,
|
|
|
|
MZ_ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIZE = 20,
|
|
|
|
MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID = 0x0001,
|
|
|
|
MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID = 0x0001,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTOR_ID = 0x08074b50,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTOR_ID = 0x08074b50,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTER_SIZE64 = 24,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTER_SIZE64 = 24,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTER_SIZE32 = 16,
|
|
|
|
MZ_ZIP_DATA_DESCRIPTER_SIZE32 = 16,
|
|
|
|
|
|
|
|
|
|
|
|
/* Central directory header record offsets */
|
|
|
|
/* Central directory header record offsets */
|
|
|
|
MZ_ZIP_CDH_SIG_OFS = 0,
|
|
|
|
MZ_ZIP_CDH_SIG_OFS = 0,
|
|
|
|
@@ -199,7 +204,7 @@ enum
|
|
|
|
MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22,
|
|
|
|
MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22,
|
|
|
|
MZ_ZIP_LDH_FILENAME_LEN_OFS = 26,
|
|
|
|
MZ_ZIP_LDH_FILENAME_LEN_OFS = 26,
|
|
|
|
MZ_ZIP_LDH_EXTRA_LEN_OFS = 28,
|
|
|
|
MZ_ZIP_LDH_EXTRA_LEN_OFS = 28,
|
|
|
|
MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR = 1<<3,
|
|
|
|
MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR = 1 << 3,
|
|
|
|
|
|
|
|
|
|
|
|
/* End of central directory offsets */
|
|
|
|
/* End of central directory offsets */
|
|
|
|
MZ_ZIP_ECDH_SIG_OFS = 0,
|
|
|
|
MZ_ZIP_ECDH_SIG_OFS = 0,
|
|
|
|
@@ -234,7 +239,7 @@ enum
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG = 32,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_COMPRESSED_PATCH_FLAG = 32,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION = 64,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION = 64,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED = 8192,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_LOCAL_DIR_IS_MASKED = 8192,
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 = 1<<11
|
|
|
|
MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8 = 1 << 11
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
typedef struct
|
|
|
|
@@ -741,11 +746,14 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mz_uint32 field_id;
|
|
|
|
|
|
|
|
mz_uint32 field_data_size;
|
|
|
|
|
|
|
|
|
|
|
|
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
|
|
|
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 field_id = MZ_READ_LE16(pExtra_data);
|
|
|
|
field_id = MZ_READ_LE16(pExtra_data);
|
|
|
|
mz_uint32 field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
|
|
|
|
field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
|
|
|
|
|
|
|
|
|
|
|
|
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
|
|
|
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
@@ -899,6 +907,7 @@ mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t si
|
|
|
|
pZip->m_archive_size = size;
|
|
|
|
pZip->m_archive_size = size;
|
|
|
|
pZip->m_pRead = mz_zip_mem_read_func;
|
|
|
|
pZip->m_pRead = mz_zip_mem_read_func;
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#ifdef __cplusplus
|
|
|
|
pZip->m_pState->m_pMem = const_cast<void *>(pMem);
|
|
|
|
pZip->m_pState->m_pMem = const_cast<void *>(pMem);
|
|
|
|
@@ -938,11 +947,13 @@ mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size)
|
|
|
|
mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags, mz_uint64 file_start_ofs, mz_uint64 archive_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mz_uint64 file_size;
|
|
|
|
|
|
|
|
MZ_FILE *pFile;
|
|
|
|
|
|
|
|
|
|
|
|
if ((!pZip) || (!pFilename) || ((archive_size) && (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))
|
|
|
|
if ((!pZip) || (!pFilename) || ((archive_size) && (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint64 file_size;
|
|
|
|
pFile = MZ_FOPEN(pFilename, "rb");
|
|
|
|
MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb");
|
|
|
|
|
|
|
|
if (!pFile)
|
|
|
|
if (!pFile)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_OPEN_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1174,11 +1185,14 @@ static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_inde
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mz_uint32 field_id;
|
|
|
|
|
|
|
|
mz_uint32 field_data_size;
|
|
|
|
|
|
|
|
|
|
|
|
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
|
|
|
if (extra_size_remaining < (sizeof(mz_uint16) * 2))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 field_id = MZ_READ_LE16(pExtra_data);
|
|
|
|
field_id = MZ_READ_LE16(pExtra_data);
|
|
|
|
mz_uint32 field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
|
|
|
|
field_data_size = MZ_READ_LE16(pExtra_data + sizeof(mz_uint16));
|
|
|
|
|
|
|
|
|
|
|
|
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
|
|
|
if ((field_data_size + sizeof(mz_uint16) * 2) > extra_size_remaining)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_HEADER_OR_CORRUPTED);
|
|
|
|
@@ -1304,7 +1318,7 @@ static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char
|
|
|
|
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
|
|
|
|
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint32 index;
|
|
|
|
mz_uint32 index;
|
|
|
|
if(!mz_zip_reader_locate_file_v2(pZip, pName, pComment, flags, &index))
|
|
|
|
if (!mz_zip_reader_locate_file_v2(pZip, pName, pComment, flags, &index))
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return (int)index;
|
|
|
|
return (int)index;
|
|
|
|
@@ -1969,15 +1983,15 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
|
|
|
|
|
|
|
|
|
|
|
|
if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
|
|
|
|
if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
mz_uint32 extra_size_remaining = local_header_extra_len;
|
|
|
|
|
|
|
|
const mz_uint8 *pExtra_data = (const mz_uint8 *)file_data_array.m_p;
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len, file_data_array.m_p, local_header_extra_len) != local_header_extra_len)
|
|
|
|
if (pZip->m_pRead(pZip->m_pIO_opaque, local_header_ofs + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + local_header_filename_len, file_data_array.m_p, local_header_extra_len) != local_header_extra_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
|
|
|
mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
|
|
|
goto handle_failure;
|
|
|
|
goto handle_failure;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 extra_size_remaining = local_header_extra_len;
|
|
|
|
|
|
|
|
const mz_uint8 *pExtra_data = (const mz_uint8 *)file_data_array.m_p;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint32 field_id, field_data_size, field_total_size;
|
|
|
|
mz_uint32 field_id, field_data_size, field_total_size;
|
|
|
|
@@ -2019,6 +2033,10 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
|
|
|
|
if ((has_data_descriptor) && (!local_header_comp_size) && (!local_header_crc32))
|
|
|
|
if ((has_data_descriptor) && (!local_header_comp_size) && (!local_header_crc32))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint8 descriptor_buf[32];
|
|
|
|
mz_uint8 descriptor_buf[32];
|
|
|
|
|
|
|
|
mz_bool has_id;
|
|
|
|
|
|
|
|
const mz_uint8 *pSrc;
|
|
|
|
|
|
|
|
mz_uint32 file_crc32;
|
|
|
|
|
|
|
|
mz_uint64 comp_size = 0, uncomp_size = 0;
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 num_descriptor_uint32s = ((pState->m_zip64) || (found_zip64_ext_data_in_ldir)) ? 6 : 4;
|
|
|
|
mz_uint32 num_descriptor_uint32s = ((pState->m_zip64) || (found_zip64_ext_data_in_ldir)) ? 6 : 4;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2028,11 +2046,10 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
|
|
|
|
goto handle_failure;
|
|
|
|
goto handle_failure;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool has_id = (MZ_READ_LE32(descriptor_buf) == MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
has_id = (MZ_READ_LE32(descriptor_buf) == MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
const mz_uint8 *pSrc = has_id ? (descriptor_buf + sizeof(mz_uint32)) : descriptor_buf;
|
|
|
|
pSrc = has_id ? (descriptor_buf + sizeof(mz_uint32)) : descriptor_buf;
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 file_crc32 = MZ_READ_LE32(pSrc);
|
|
|
|
file_crc32 = MZ_READ_LE32(pSrc);
|
|
|
|
mz_uint64 comp_size = 0, uncomp_size = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((pState->m_zip64) || (found_zip64_ext_data_in_ldir))
|
|
|
|
if ((pState->m_zip64) || (found_zip64_ext_data_in_ldir))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -2329,7 +2346,7 @@ static mz_bool mz_zip_writer_end_internal(mz_zip_archive *pZip, mz_bool set_last
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags)
|
|
|
|
mz_bool mz_zip_writer_init_v2(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uint flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_bool zip64 = (flags & MZ_ZIP_FLAG_WRITE_ZIP64) != 0;
|
|
|
|
mz_bool zip64 = (flags & MZ_ZIP_FLAG_WRITE_ZIP64) != 0;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2378,16 +2395,22 @@ mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size, mz_uin
|
|
|
|
return MZ_TRUE;
|
|
|
|
return MZ_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags)
|
|
|
|
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mz_zip_writer_init_v2(pZip, existing_size, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init_heap_v2(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size, mz_uint flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pZip->m_pWrite = mz_zip_heap_write_func;
|
|
|
|
pZip->m_pWrite = mz_zip_heap_write_func;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
pZip->m_pRead = mz_zip_mem_read_func;
|
|
|
|
pZip->m_pRead = mz_zip_mem_read_func;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning, flags))
|
|
|
|
if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags))
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_zip_type = MZ_ZIP_TYPE_HEAP;
|
|
|
|
pZip->m_zip_type = MZ_ZIP_TYPE_HEAP;
|
|
|
|
@@ -2405,6 +2428,11 @@ mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_
|
|
|
|
return MZ_TRUE;
|
|
|
|
return MZ_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mz_zip_writer_init_heap_v2(pZip, size_to_reserve_at_beginning, initial_allocation_size, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MINIZ_NO_STDIO
|
|
|
|
#ifndef MINIZ_NO_STDIO
|
|
|
|
static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
|
|
|
|
static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -2432,13 +2460,14 @@ mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename,
|
|
|
|
MZ_FILE *pFile;
|
|
|
|
MZ_FILE *pFile;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
pZip->m_pRead = mz_zip_file_read_func;
|
|
|
|
pZip->m_pRead = mz_zip_file_read_func;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning, flags))
|
|
|
|
if (!mz_zip_writer_init_v2(pZip, size_to_reserve_at_beginning, flags))
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
if (NULL == (pFile = MZ_FOPEN(pFilename, (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) ? "w+b" : "wb")))
|
|
|
|
if (NULL == (pFile = MZ_FOPEN(pFilename, (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING) ? "w+b" : "wb")))
|
|
|
|
@@ -2476,13 +2505,14 @@ mz_bool mz_zip_writer_init_file_v2(mz_zip_archive *pZip, const char *pFilename,
|
|
|
|
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags)
|
|
|
|
mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
if (flags & MZ_ZIP_FLAG_WRITE_ALLOW_READING)
|
|
|
|
pZip->m_pRead = mz_zip_file_read_func;
|
|
|
|
pZip->m_pRead = mz_zip_file_read_func;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
pZip->m_pIO_opaque = pZip;
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_init(pZip, 0, flags))
|
|
|
|
if (!mz_zip_writer_init_v2(pZip, 0, flags))
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pState->m_pFile = pFile;
|
|
|
|
pZip->m_pState->m_pFile = pFile;
|
|
|
|
@@ -2493,7 +2523,7 @@ mz_bool mz_zip_writer_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint f
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* #ifndef MINIZ_NO_STDIO */
|
|
|
|
#endif /* #ifndef MINIZ_NO_STDIO */
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
|
|
|
|
mz_bool mz_zip_writer_init_from_reader_v2(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_zip_internal_state *pState;
|
|
|
|
mz_zip_internal_state *pState;
|
|
|
|
|
|
|
|
|
|
|
|
@@ -2548,6 +2578,7 @@ mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilena
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
pZip->m_pWrite = mz_zip_file_write_func;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
#endif /* #ifdef MINIZ_NO_STDIO */
|
|
|
|
#endif /* #ifdef MINIZ_NO_STDIO */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pState->m_pMem)
|
|
|
|
else if (pState->m_pMem)
|
|
|
|
@@ -2558,6 +2589,7 @@ mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilena
|
|
|
|
|
|
|
|
|
|
|
|
pState->m_mem_capacity = pState->m_mem_size;
|
|
|
|
pState->m_mem_capacity = pState->m_mem_size;
|
|
|
|
pZip->m_pWrite = mz_zip_heap_write_func;
|
|
|
|
pZip->m_pWrite = mz_zip_heap_write_func;
|
|
|
|
|
|
|
|
pZip->m_pNeeds_keepalive = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Archive is being read via a user provided read function - make sure the user has specified a write function too. */
|
|
|
|
/* Archive is being read via a user provided read function - make sure the user has specified a write function too. */
|
|
|
|
else if (!pZip->m_pWrite)
|
|
|
|
else if (!pZip->m_pWrite)
|
|
|
|
@@ -2578,6 +2610,11 @@ mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilena
|
|
|
|
return MZ_TRUE;
|
|
|
|
return MZ_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mz_zip_writer_init_from_reader_v2(pZip, pFilename, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* TODO: pArchive_name is a terrible name here! */
|
|
|
|
/* TODO: pArchive_name is a terrible name here! */
|
|
|
|
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags)
|
|
|
|
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -2607,13 +2644,12 @@ static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len, voi
|
|
|
|
static mz_uint32 mz_zip_writer_create_zip64_extra_data(mz_uint8 *pBuf, mz_uint64 *pUncomp_size, mz_uint64 *pComp_size, mz_uint64 *pLocal_header_ofs)
|
|
|
|
static mz_uint32 mz_zip_writer_create_zip64_extra_data(mz_uint8 *pBuf, mz_uint64 *pUncomp_size, mz_uint64 *pComp_size, mz_uint64 *pLocal_header_ofs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint8 *pDst = pBuf;
|
|
|
|
mz_uint8 *pDst = pBuf;
|
|
|
|
|
|
|
|
mz_uint32 field_size = 0;
|
|
|
|
|
|
|
|
|
|
|
|
MZ_WRITE_LE16(pDst + 0, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID);
|
|
|
|
MZ_WRITE_LE16(pDst + 0, MZ_ZIP64_EXTENDED_INFORMATION_FIELD_HEADER_ID);
|
|
|
|
MZ_WRITE_LE16(pDst + 2, 0);
|
|
|
|
MZ_WRITE_LE16(pDst + 2, 0);
|
|
|
|
pDst += sizeof(mz_uint16) * 2;
|
|
|
|
pDst += sizeof(mz_uint16) * 2;
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 field_size = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pUncomp_size)
|
|
|
|
if (pUncomp_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MZ_WRITE_LE64(pDst, *pUncomp_size);
|
|
|
|
MZ_WRITE_LE64(pDst, *pUncomp_size);
|
|
|
|
@@ -2688,7 +2724,7 @@ static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char
|
|
|
|
mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32,
|
|
|
|
mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32,
|
|
|
|
mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,
|
|
|
|
mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,
|
|
|
|
mz_uint64 local_header_ofs, mz_uint32 ext_attributes,
|
|
|
|
mz_uint64 local_header_ofs, mz_uint32 ext_attributes,
|
|
|
|
const char* user_extra_data, mz_uint user_extra_data_len)
|
|
|
|
const char *user_extra_data, mz_uint user_extra_data_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_zip_internal_state *pState = pZip->m_pState;
|
|
|
|
mz_zip_internal_state *pState = pZip->m_pState;
|
|
|
|
mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;
|
|
|
|
mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;
|
|
|
|
@@ -2711,7 +2747,7 @@ static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char
|
|
|
|
if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||
|
|
|
|
if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, user_extra_data, user_extra_data_len)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, user_extra_data, user_extra_data_len)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) ||
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1)))
|
|
|
|
(!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -2772,8 +2808,8 @@ mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size,
|
|
|
|
mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size,
|
|
|
|
mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified,
|
|
|
|
mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified,
|
|
|
|
const char* user_extra_data, mz_uint user_extra_data_len, const char* user_extra_data_central, mz_uint user_extra_data_central_len)
|
|
|
|
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint16 method = 0, dos_time = 0, dos_date = 0;
|
|
|
|
mz_uint16 method = 0, dos_time = 0, dos_date = 0;
|
|
|
|
mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
|
|
|
|
mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
|
|
|
|
@@ -2788,10 +2824,10 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
|
|
|
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
|
|
|
mz_uint16 bit_flags = 0;
|
|
|
|
mz_uint16 bit_flags = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if(uncomp_size)
|
|
|
|
if (uncomp_size || (buf_size && !(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
|
|
|
|
bit_flags |= MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
|
|
|
bit_flags |= MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
|
|
|
|
|
|
|
|
|
|
|
if (level_and_flags & MZ_ZIP_FLAG_UTF8_FILENAME )
|
|
|
|
if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
|
|
|
|
bit_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
|
|
|
bit_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
|
|
|
|
|
|
|
|
|
|
|
if ((int)level_and_flags < 0)
|
|
|
|
if ((int)level_and_flags < 0)
|
|
|
|
@@ -2811,16 +2847,16 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pZip->m_total_files == MZ_UINT16_MAX)
|
|
|
|
if (pZip->m_total_files == MZ_UINT16_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
|
|
|
|
if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))
|
|
|
|
if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))
|
|
|
|
@@ -2829,20 +2865,20 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
if (!mz_zip_writer_validate_archive_name(pArchive_name))
|
|
|
|
if (!mz_zip_writer_validate_archive_name(pArchive_name))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_FILENAME);
|
|
|
|
|
|
|
|
|
|
|
|
if (last_modified != NULL)
|
|
|
|
if (last_modified != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_zip_time_t_to_dos_time(*last_modified, &dos_time, &dos_date);
|
|
|
|
mz_zip_time_t_to_dos_time(*last_modified, &dos_time, &dos_date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifndef MINIZ_NO_TIME
|
|
|
|
#ifndef MINIZ_NO_TIME
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MZ_TIME_T cur_time;
|
|
|
|
MZ_TIME_T cur_time;
|
|
|
|
time(&cur_time);
|
|
|
|
time(&cur_time);
|
|
|
|
mz_zip_time_t_to_dos_time(cur_time, &dos_time, &dos_date);
|
|
|
|
mz_zip_time_t_to_dos_time(cur_time, &dos_time, &dos_date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* #ifndef MINIZ_NO_TIME */
|
|
|
|
#endif /* #ifndef MINIZ_NO_TIME */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
archive_name_size = strlen(pArchive_name);
|
|
|
|
archive_name_size = strlen(pArchive_name);
|
|
|
|
if (archive_name_size > MZ_UINT16_MAX)
|
|
|
|
if (archive_name_size > MZ_UINT16_MAX)
|
|
|
|
@@ -2857,11 +2893,11 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
if (!pState->m_zip64)
|
|
|
|
if (!pState->m_zip64)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Bail early if the archive would obviously become too large */
|
|
|
|
/* Bail early if the archive would obviously become too large */
|
|
|
|
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)
|
|
|
|
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/'))
|
|
|
|
if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/'))
|
|
|
|
@@ -2899,70 +2935,70 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
|
|
|
|
|
|
|
|
MZ_CLEAR_OBJ(local_dir_header);
|
|
|
|
MZ_CLEAR_OBJ(local_dir_header);
|
|
|
|
|
|
|
|
|
|
|
|
if (!store_data_uncompressed || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
|
|
|
if (!store_data_uncompressed || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
method = MZ_DEFLATED;
|
|
|
|
method = MZ_DEFLATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pState->m_zip64)
|
|
|
|
if (pState->m_zip64)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
|
|
|
|
if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pExtra_data = extra_data;
|
|
|
|
pExtra_data = extra_data;
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
|
|
|
|
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += extra_size;
|
|
|
|
cur_archive_file_ofs += extra_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, bit_flags, dos_time, dos_date))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (user_extra_data_len > 0)
|
|
|
|
if (user_extra_data_len > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += user_extra_data_len;
|
|
|
|
cur_archive_file_ofs += user_extra_data_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
|
|
|
if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -3008,45 +3044,45 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
|
|
|
|
pComp = NULL;
|
|
|
|
pComp = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (uncomp_size)
|
|
|
|
if (uncomp_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MZ_ASSERT(bit_flags & MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
|
|
|
|
mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
|
|
|
|
mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
|
|
|
|
mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
|
|
|
|
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
MZ_ASSERT(bit_flags & MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
|
|
|
|
|
|
|
|
if (pExtra_data==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
|
|
|
|
}
|
|
|
|
if (pExtra_data == NULL)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
|
|
|
|
|
|
|
|
local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
|
|
|
|
return MZ_FALSE;
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
|
|
|
|
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
|
|
|
|
|
|
|
|
local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += local_dir_footer_size;
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
|
|
|
|
}
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
cur_archive_file_ofs += local_dir_footer_size;
|
|
|
|
{
|
|
|
|
}
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment,
|
|
|
|
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment,
|
|
|
|
comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
|
|
|
comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
|
|
|
user_extra_data_central, user_extra_data_central_len))
|
|
|
|
user_extra_data_central, user_extra_data_central_len))
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_total_files++;
|
|
|
|
pZip->m_total_files++;
|
|
|
|
@@ -3057,7 +3093,7 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MINIZ_NO_STDIO
|
|
|
|
#ifndef MINIZ_NO_STDIO
|
|
|
|
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
|
|
mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name, MZ_FILE *pSrc_file, mz_uint64 size_to_add, const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags,
|
|
|
|
const char* user_extra_data, mz_uint user_extra_data_len, const char* user_extra_data_central, mz_uint user_extra_data_central_len)
|
|
|
|
const char *user_extra_data, mz_uint user_extra_data_len, const char *user_extra_data_central, mz_uint user_extra_data_central_len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
|
|
|
mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
|
|
|
mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
|
|
|
|
mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
|
|
|
|
@@ -3070,7 +3106,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
|
|
|
mz_uint8 extra_data[MZ_ZIP64_MAX_CENTRAL_EXTRA_FIELD_SIZE];
|
|
|
|
mz_zip_internal_state *pState;
|
|
|
|
mz_zip_internal_state *pState;
|
|
|
|
|
|
|
|
|
|
|
|
if(level_and_flags & MZ_ZIP_FLAG_UTF8_FILENAME)
|
|
|
|
if (!(level_and_flags & MZ_ZIP_FLAG_ASCII_FILENAME))
|
|
|
|
gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
|
|
|
gen_flags |= MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_UTF8;
|
|
|
|
|
|
|
|
|
|
|
|
if ((int)level_and_flags < 0)
|
|
|
|
if ((int)level_and_flags < 0)
|
|
|
|
@@ -3087,7 +3123,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Source file is too large for non-zip64 */
|
|
|
|
/* Source file is too large for non-zip64 */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* We could support this, but why? */
|
|
|
|
/* We could support this, but why? */
|
|
|
|
@@ -3104,11 +3140,11 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pZip->m_total_files == MZ_UINT16_MAX)
|
|
|
|
if (pZip->m_total_files == MZ_UINT16_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_TOO_MANY_FILES); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
archive_name_size = strlen(pArchive_name);
|
|
|
|
archive_name_size = strlen(pArchive_name);
|
|
|
|
@@ -3124,11 +3160,11 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
if (!pState->m_zip64)
|
|
|
|
if (!pState->m_zip64)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* Bail early if the archive would obviously become too large */
|
|
|
|
/* Bail early if the archive would obviously become too large */
|
|
|
|
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE+1024) > 0xFFFFFFFF)
|
|
|
|
if ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + archive_name_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE + 1024) > 0xFFFFFFFF)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
pState->m_zip64 = MZ_TRUE;
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
/*return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE); */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MINIZ_NO_TIME
|
|
|
|
#ifndef MINIZ_NO_TIME
|
|
|
|
@@ -3146,76 +3182,76 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += num_alignment_padding_bytes;
|
|
|
|
cur_archive_file_ofs += num_alignment_padding_bytes;
|
|
|
|
local_dir_header_ofs = cur_archive_file_ofs;
|
|
|
|
local_dir_header_ofs = cur_archive_file_ofs;
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_file_offset_alignment)
|
|
|
|
if (pZip->m_file_offset_alignment)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
MZ_ASSERT((cur_archive_file_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
|
|
|
|
MZ_ASSERT((cur_archive_file_ofs & (pZip->m_file_offset_alignment - 1)) == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (uncomp_size && level)
|
|
|
|
if (uncomp_size && level)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
method = MZ_DEFLATED;
|
|
|
|
method = MZ_DEFLATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MZ_CLEAR_OBJ(local_dir_header);
|
|
|
|
MZ_CLEAR_OBJ(local_dir_header);
|
|
|
|
if (pState->m_zip64)
|
|
|
|
if (pState->m_zip64)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
|
|
|
|
if (uncomp_size >= MZ_UINT32_MAX || local_dir_header_ofs >= MZ_UINT32_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pExtra_data = extra_data;
|
|
|
|
pExtra_data = extra_data;
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size+ user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, extra_size + user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, extra_data, extra_size) != extra_size)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += extra_size;
|
|
|
|
cur_archive_file_ofs += extra_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
if ((comp_size > MZ_UINT32_MAX) || (cur_archive_file_ofs > MZ_UINT32_MAX))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
|
|
|
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, user_extra_data_len, 0, 0, 0, method, gen_flags, dos_time, dos_date))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_INTERNAL_ERROR);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
cur_archive_file_ofs += sizeof(local_dir_header);
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
cur_archive_file_ofs += archive_name_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (user_extra_data_len > 0)
|
|
|
|
if (user_extra_data_len > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, user_extra_data, user_extra_data_len) != user_extra_data_len)
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_WRITE_FAILED);
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += user_extra_data_len;
|
|
|
|
cur_archive_file_ofs += user_extra_data_len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (uncomp_size)
|
|
|
|
if (uncomp_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -3268,6 +3304,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
|
|
|
|
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE);
|
|
|
|
tdefl_status status;
|
|
|
|
tdefl_status status;
|
|
|
|
|
|
|
|
tdefl_flush flush = TDEFL_NO_FLUSH;
|
|
|
|
|
|
|
|
|
|
|
|
if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
|
|
|
|
if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -3278,7 +3315,10 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
|
|
|
|
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
|
|
|
|
uncomp_remaining -= in_buf_size;
|
|
|
|
uncomp_remaining -= in_buf_size;
|
|
|
|
|
|
|
|
|
|
|
|
status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH);
|
|
|
|
if (pZip->m_pNeeds_keepalive != NULL && pZip->m_pNeeds_keepalive(pZip->m_pIO_opaque))
|
|
|
|
|
|
|
|
flush = TDEFL_FULL_FLUSH;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? flush : TDEFL_FINISH);
|
|
|
|
if (status == TDEFL_STATUS_DONE)
|
|
|
|
if (status == TDEFL_STATUS_DONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = MZ_TRUE;
|
|
|
|
result = MZ_TRUE;
|
|
|
|
@@ -3306,40 +3346,42 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
|
|
|
|
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
|
|
|
|
|
|
|
|
mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
|
|
|
|
|
|
|
|
if (pExtra_data==NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (comp_size > MZ_UINT32_MAX)
|
|
|
|
mz_uint8 local_dir_footer[MZ_ZIP_DATA_DESCRIPTER_SIZE64];
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
mz_uint32 local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE32;
|
|
|
|
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 0, MZ_ZIP_DATA_DESCRIPTOR_ID);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 4, uncomp_crc32);
|
|
|
|
}
|
|
|
|
if (pExtra_data == NULL)
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (comp_size > MZ_UINT32_MAX)
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_ARCHIVE_TOO_LARGE);
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
|
|
|
|
|
|
|
|
local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 8, comp_size);
|
|
|
|
|
|
|
|
MZ_WRITE_LE32(local_dir_footer + 12, uncomp_size);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 8, comp_size);
|
|
|
|
|
|
|
|
MZ_WRITE_LE64(local_dir_footer + 16, uncomp_size);
|
|
|
|
|
|
|
|
local_dir_footer_size = MZ_ZIP_DATA_DESCRIPTER_SIZE64;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
|
|
|
|
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cur_archive_file_ofs += local_dir_footer_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, local_dir_footer, local_dir_footer_size) != local_dir_footer_size)
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
return MZ_FALSE;
|
|
|
|
{
|
|
|
|
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
cur_archive_file_ofs += local_dir_footer_size;
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (pExtra_data != NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
extra_size = mz_zip_writer_create_zip64_extra_data(extra_data, (uncomp_size >= MZ_UINT32_MAX) ? &uncomp_size : NULL,
|
|
|
|
|
|
|
|
(uncomp_size >= MZ_UINT32_MAX) ? &comp_size : NULL, (local_dir_header_ofs >= MZ_UINT32_MAX) ? &local_dir_header_ofs : NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment, comment_size,
|
|
|
|
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, pExtra_data, extra_size, pComment, comment_size,
|
|
|
|
uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
|
|
|
uncomp_size, comp_size, uncomp_crc32, method, gen_flags, dos_time, dos_date, local_dir_header_ofs, ext_attributes,
|
|
|
|
user_extra_data_central, user_extra_data_central_len))
|
|
|
|
user_extra_data_central, user_extra_data_central_len))
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
pZip->m_total_files++;
|
|
|
|
pZip->m_total_files++;
|
|
|
|
@@ -3354,6 +3396,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
mz_uint64 uncomp_size = 0;
|
|
|
|
mz_uint64 uncomp_size = 0;
|
|
|
|
MZ_TIME_T file_modified_time;
|
|
|
|
MZ_TIME_T file_modified_time;
|
|
|
|
MZ_TIME_T *pFile_time = NULL;
|
|
|
|
MZ_TIME_T *pFile_time = NULL;
|
|
|
|
|
|
|
|
mz_bool status;
|
|
|
|
|
|
|
|
|
|
|
|
memset(&file_modified_time, 0, sizeof(file_modified_time));
|
|
|
|
memset(&file_modified_time, 0, sizeof(file_modified_time));
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3371,7 +3414,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
|
|
|
uncomp_size = MZ_FTELL64(pSrc_file);
|
|
|
|
uncomp_size = MZ_FTELL64(pSrc_file);
|
|
|
|
MZ_FSEEK64(pSrc_file, 0, SEEK_SET);
|
|
|
|
MZ_FSEEK64(pSrc_file, 0, SEEK_SET);
|
|
|
|
|
|
|
|
|
|
|
|
mz_bool status = mz_zip_writer_add_cfile(pZip, pArchive_name, pSrc_file, uncomp_size, pFile_time, pComment, comment_size, level_and_flags, NULL, 0, NULL, 0);
|
|
|
|
status = mz_zip_writer_add_cfile(pZip, pArchive_name, pSrc_file, uncomp_size, pFile_time, pComment, comment_size, level_and_flags, NULL, 0, NULL, 0);
|
|
|
|
|
|
|
|
|
|
|
|
MZ_FCLOSE(pSrc_file);
|
|
|
|
MZ_FCLOSE(pSrc_file);
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3543,6 +3586,9 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *
|
|
|
|
if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
|
|
|
|
if ((local_header_extra_len) && ((local_header_comp_size == MZ_UINT32_MAX) || (local_header_uncomp_size == MZ_UINT32_MAX)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_zip_array file_data_array;
|
|
|
|
mz_zip_array file_data_array;
|
|
|
|
|
|
|
|
const mz_uint8 *pExtra_data;
|
|
|
|
|
|
|
|
mz_uint32 extra_size_remaining = local_header_extra_len;
|
|
|
|
|
|
|
|
|
|
|
|
mz_zip_array_init(&file_data_array, 1);
|
|
|
|
mz_zip_array_init(&file_data_array, 1);
|
|
|
|
if (!mz_zip_array_resize(pZip, &file_data_array, local_header_extra_len, MZ_FALSE))
|
|
|
|
if (!mz_zip_array_resize(pZip, &file_data_array, local_header_extra_len, MZ_FALSE))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -3555,8 +3601,7 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
|
|
|
return mz_zip_set_error(pZip, MZ_ZIP_FILE_READ_FAILED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mz_uint32 extra_size_remaining = local_header_extra_len;
|
|
|
|
pExtra_data = (const mz_uint8 *)file_data_array.m_p;
|
|
|
|
const mz_uint8 *pExtra_data = (const mz_uint8 *)file_data_array.m_p;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
do
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -3992,7 +4037,7 @@ mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, co
|
|
|
|
return MZ_FALSE;
|
|
|
|
return MZ_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename, level_and_flags))
|
|
|
|
if (!mz_zip_writer_init_from_reader_v2(&zip_archive, pZip_filename, level_and_flags))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pErr)
|
|
|
|
if (pErr)
|
|
|
|
*pErr = zip_archive.m_last_error;
|
|
|
|
*pErr = zip_archive.m_last_error;
|
|
|
|
@@ -4036,7 +4081,7 @@ mz_bool mz_zip_add_mem_to_archive_file_in_place_v2(const char *pZip_filename, co
|
|
|
|
return status;
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr)
|
|
|
|
void *mz_zip_extract_archive_file_to_heap_v2(const char *pZip_filename, const char *pArchive_name, const char *pComment, size_t *pSize, mz_uint flags, mz_zip_error *pErr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mz_uint32 file_index;
|
|
|
|
mz_uint32 file_index;
|
|
|
|
mz_zip_archive zip_archive;
|
|
|
|
mz_zip_archive zip_archive;
|
|
|
|
@@ -4075,6 +4120,11 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return mz_zip_extract_archive_file_to_heap_v2(pZip_filename, pArchive_name, NULL, pSize, flags, NULL);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* #ifndef MINIZ_NO_STDIO */
|
|
|
|
#endif /* #ifndef MINIZ_NO_STDIO */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
|
|
|
|
#endif /* #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS */
|
|
|
|
@@ -4298,4 +4348,3 @@ mz_bool mz_zip_end(mz_zip_archive *pZip)
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|