Int types clarification
This commit is contained in:
parent
02e7311f17
commit
bbc49f0e25
40
miniz.c
40
miniz.c
@ -256,14 +256,14 @@ int mz_deflate(mz_streamp pStream, int flush)
|
||||
out_bytes = pStream->avail_out;
|
||||
|
||||
defl_status = tdefl_compress((tdefl_compressor *)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush);
|
||||
pStream->next_in += (mz_uint)in_bytes;
|
||||
pStream->avail_in -= (mz_uint)in_bytes;
|
||||
pStream->total_in += (mz_uint)in_bytes;
|
||||
pStream->next_in += (mz_uint32)in_bytes;
|
||||
pStream->avail_in -= (mz_uint32)in_bytes;
|
||||
pStream->total_in += (mz_uint32)in_bytes;
|
||||
pStream->adler = tdefl_get_adler32((tdefl_compressor *)pStream->state);
|
||||
|
||||
pStream->next_out += (mz_uint)out_bytes;
|
||||
pStream->avail_out -= (mz_uint)out_bytes;
|
||||
pStream->total_out += (mz_uint)out_bytes;
|
||||
pStream->next_out += (mz_uint32)out_bytes;
|
||||
pStream->avail_out -= (mz_uint32)out_bytes;
|
||||
pStream->total_out += (mz_uint32)out_bytes;
|
||||
|
||||
if (defl_status < 0)
|
||||
{
|
||||
@ -350,7 +350,8 @@ mz_ulong mz_compressBound(mz_ulong source_len)
|
||||
typedef struct
|
||||
{
|
||||
tinfl_decompressor m_decomp;
|
||||
mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed;
|
||||
mz_uint32 m_dict_ofs, m_dict_avail;
|
||||
mz_uint m_first_call, m_has_flushed;
|
||||
int m_window_bits;
|
||||
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE];
|
||||
tinfl_status m_last_status;
|
||||
@ -400,7 +401,8 @@ int mz_inflateInit(mz_streamp pStream)
|
||||
int mz_inflate(mz_streamp pStream, int flush)
|
||||
{
|
||||
inflate_state *pState;
|
||||
mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
|
||||
mz_uint32 n, first_call;
|
||||
mz_uint decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
|
||||
size_t in_bytes, out_bytes, orig_avail_in;
|
||||
tinfl_status status;
|
||||
|
||||
@ -433,13 +435,13 @@ int mz_inflate(mz_streamp pStream, int flush)
|
||||
out_bytes = pStream->avail_out;
|
||||
status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags);
|
||||
pState->m_last_status = status;
|
||||
pStream->next_in += (mz_uint)in_bytes;
|
||||
pStream->avail_in -= (mz_uint)in_bytes;
|
||||
pStream->total_in += (mz_uint)in_bytes;
|
||||
pStream->next_in += (mz_uint32)in_bytes;
|
||||
pStream->avail_in -= (mz_uint32)in_bytes;
|
||||
pStream->total_in += (mz_uint32)in_bytes;
|
||||
pStream->adler = tinfl_get_adler32(&pState->m_decomp);
|
||||
pStream->next_out += (mz_uint)out_bytes;
|
||||
pStream->avail_out -= (mz_uint)out_bytes;
|
||||
pStream->total_out += (mz_uint)out_bytes;
|
||||
pStream->next_out += (mz_uint32)out_bytes;
|
||||
pStream->avail_out -= (mz_uint32)out_bytes;
|
||||
pStream->total_out += (mz_uint32)out_bytes;
|
||||
|
||||
if (status < 0)
|
||||
return MZ_DATA_ERROR;
|
||||
@ -474,12 +476,12 @@ int mz_inflate(mz_streamp pStream, int flush)
|
||||
status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
|
||||
pState->m_last_status = status;
|
||||
|
||||
pStream->next_in += (mz_uint)in_bytes;
|
||||
pStream->avail_in -= (mz_uint)in_bytes;
|
||||
pStream->total_in += (mz_uint)in_bytes;
|
||||
pStream->next_in += (mz_uint32)in_bytes;
|
||||
pStream->avail_in -= (mz_uint32)in_bytes;
|
||||
pStream->total_in += (mz_uint32)in_bytes;
|
||||
pStream->adler = tinfl_get_adler32(&pState->m_decomp);
|
||||
|
||||
pState->m_dict_avail = (mz_uint)out_bytes;
|
||||
pState->m_dict_avail = (mz_uint32)out_bytes;
|
||||
|
||||
n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
|
||||
memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
|
||||
@ -561,7 +563,7 @@ const char *mz_error(int err)
|
||||
{
|
||||
{ MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" }, { MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" }
|
||||
};
|
||||
mz_uint i;
|
||||
mz_uint32 i;
|
||||
for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i)
|
||||
if (s_error_descs[i].m_err == err)
|
||||
return s_error_descs[i].m_pDesc;
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
typedef unsigned char mz_uint8;
|
||||
typedef signed short mz_int16;
|
||||
typedef unsigned short mz_uint16;
|
||||
typedef unsigned int mz_uint32;
|
||||
typedef unsigned int mz_uint;
|
||||
typedef uint32_t mz_uint32;
|
||||
typedef int64_t mz_int64;
|
||||
typedef uint64_t mz_uint64;
|
||||
typedef int mz_bool;
|
||||
|
||||
118
miniz_zip.c
118
miniz_zip.c
@ -248,7 +248,7 @@ typedef struct
|
||||
{
|
||||
void *m_p;
|
||||
size_t m_size, m_capacity;
|
||||
mz_uint m_element_size;
|
||||
mz_uint32 m_element_size;
|
||||
} mz_zip_array;
|
||||
|
||||
struct mz_zip_internal_state_tag
|
||||
@ -258,7 +258,7 @@ struct mz_zip_internal_state_tag
|
||||
mz_zip_array m_sorted_central_dir_offsets;
|
||||
|
||||
/* The flags passed in when the archive is initially opened. */
|
||||
uint32_t m_init_flags;
|
||||
mz_uint32 m_init_flags;
|
||||
|
||||
/* MZ_TRUE if the archive has a zip64 end of central directory headers, etc. */
|
||||
mz_bool m_zip64;
|
||||
@ -278,7 +278,7 @@ struct mz_zip_internal_state_tag
|
||||
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
|
||||
|
||||
#if defined(DEBUG) || defined(_DEBUG) || defined(NDEBUG)
|
||||
static MZ_FORCEINLINE mz_uint mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint index)
|
||||
static MZ_FORCEINLINE mz_uint32 mz_zip_array_range_check(const mz_zip_array *pArray, mz_uint32 index)
|
||||
{
|
||||
MZ_ASSERT(index < pArray->m_size);
|
||||
return index;
|
||||
@ -300,7 +300,7 @@ static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array
|
||||
memset(pArray, 0, sizeof(mz_zip_array));
|
||||
}
|
||||
|
||||
static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing)
|
||||
static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint32 growing)
|
||||
{
|
||||
void *pNew_p;
|
||||
size_t new_capacity = min_new_capacity;
|
||||
@ -320,7 +320,7 @@ static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing)
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint32 growing)
|
||||
{
|
||||
if (new_capacity > pArray->m_capacity)
|
||||
{
|
||||
@ -330,7 +330,7 @@ static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing)
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint32 growing)
|
||||
{
|
||||
if (new_size > pArray->m_capacity)
|
||||
{
|
||||
@ -462,11 +462,11 @@ static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint flags)
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index)
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint32 l_index, mz_uint32 r_index)
|
||||
{
|
||||
const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
|
||||
const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index));
|
||||
mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
mz_uint32 l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
mz_uint8 l = 0, r = 0;
|
||||
pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||
pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||
@ -559,12 +559,12 @@ static mz_bool mz_zip_reader_locate_header_sig(mz_zip_archive *pZip, mz_uint32 r
|
||||
{
|
||||
int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs);
|
||||
|
||||
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n)
|
||||
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint32)n)
|
||||
return MZ_FALSE;
|
||||
|
||||
for (i = n - 4; i >= 0; --i)
|
||||
{
|
||||
mz_uint s = MZ_READ_LE32(pBuf + i);
|
||||
mz_uint32 s = MZ_READ_LE32(pBuf + i);
|
||||
if (s == record_sig)
|
||||
{
|
||||
if ((pZip->m_archive_size - (cur_file_ofs + i)) >= record_size)
|
||||
@ -591,7 +591,7 @@ static mz_bool mz_zip_reader_locate_header_sig(mz_zip_archive *pZip, mz_uint32 r
|
||||
|
||||
static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flags)
|
||||
{
|
||||
mz_uint cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0;
|
||||
mz_uint32 cdir_size = 0, cdir_entries_on_this_disk = 0, num_this_disk = 0, cdir_disk_index = 0;
|
||||
mz_uint64 cdir_ofs = 0;
|
||||
mz_int64 cur_file_ofs = 0;
|
||||
const mz_uint8 *p;
|
||||
@ -797,7 +797,7 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
||||
|
||||
if (pZip->m_total_files)
|
||||
{
|
||||
mz_uint i, n;
|
||||
mz_uint32 i, n;
|
||||
/* Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and possibly another to hold the sorted indices. */
|
||||
if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) ||
|
||||
(!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE)))
|
||||
@ -816,7 +816,8 @@ static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint flag
|
||||
p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p;
|
||||
for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i)
|
||||
{
|
||||
mz_uint total_header_size, disk_index, bit_flags, filename_size, ext_data_size;
|
||||
mz_uint bit_flags;
|
||||
mz_uint32 total_header_size, disk_index, filename_size, ext_data_size;
|
||||
mz_uint64 comp_size, decomp_size, local_header_ofs;
|
||||
|
||||
if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG))
|
||||
@ -1040,7 +1041,7 @@ static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBu
|
||||
return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
|
||||
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint flags)
|
||||
{
|
||||
return mz_zip_reader_init_file_v2(pZip, pFilename, flags, 0, 0);
|
||||
}
|
||||
@ -1138,14 +1139,14 @@ mz_bool mz_zip_reader_init_cfile(mz_zip_archive *pZip, MZ_FILE *pFile, mz_uint64
|
||||
|
||||
#endif /* #ifndef MINIZ_NO_STDIO */
|
||||
|
||||
static MZ_FORCEINLINE const mz_uint8 *mz_zip_get_cdh(mz_zip_archive *pZip, mz_uint file_index)
|
||||
static MZ_FORCEINLINE const mz_uint8 *mz_zip_get_cdh(mz_zip_archive *pZip, mz_uint32 file_index)
|
||||
{
|
||||
if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files))
|
||||
return NULL;
|
||||
return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
|
||||
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint32 file_index)
|
||||
{
|
||||
mz_uint m_bit_flag;
|
||||
const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
|
||||
@ -1159,7 +1160,7 @@ mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index
|
||||
return (m_bit_flag & (MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_IS_ENCRYPTED | MZ_ZIP_GENERAL_PURPOSE_BIT_FLAG_USES_STRONG_ENCRYPTION)) != 0;
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index)
|
||||
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint32 file_index)
|
||||
{
|
||||
mz_uint bit_flag;
|
||||
mz_uint method;
|
||||
@ -1195,9 +1196,9 @@ mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
|
||||
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint32 file_index)
|
||||
{
|
||||
mz_uint filename_len, attribute_mapping_id, external_attr;
|
||||
mz_uint32 filename_len, attribute_mapping_id, external_attr;
|
||||
const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
|
||||
if (!p)
|
||||
{
|
||||
@ -1227,9 +1228,9 @@ mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_ind
|
||||
return MZ_FALSE;
|
||||
}
|
||||
|
||||
static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data)
|
||||
static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint32 file_index, const mz_uint8 *pCentral_dir_header, mz_zip_archive_file_stat *pStat, mz_bool *pFound_zip64_extra_data)
|
||||
{
|
||||
mz_uint n;
|
||||
mz_uint32 n;
|
||||
const mz_uint8 *p = pCentral_dir_header;
|
||||
|
||||
if (pFound_zip64_extra_data)
|
||||
@ -1347,9 +1348,9 @@ static mz_bool mz_zip_file_stat_internal(mz_zip_archive *pZip, mz_uint file_inde
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags)
|
||||
static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB, mz_uint32 len, mz_uint flags)
|
||||
{
|
||||
mz_uint i;
|
||||
mz_uint32 i;
|
||||
if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE)
|
||||
return 0 == memcmp(pA, pB, len);
|
||||
for (i = 0; i < len; ++i)
|
||||
@ -1358,10 +1359,10 @@ static MZ_FORCEINLINE mz_bool mz_zip_string_equal(const char *pA, const char *pB
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static MZ_FORCEINLINE int mz_zip_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len)
|
||||
static MZ_FORCEINLINE int mz_zip_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint32 l_index, const char *pR, mz_uint32 r_len)
|
||||
{
|
||||
const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
|
||||
mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
mz_uint32 l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
mz_uint8 l = 0, r = 0;
|
||||
pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||
pE = pL + MZ_MIN(l_len, r_len);
|
||||
@ -1381,8 +1382,8 @@ static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char
|
||||
const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
|
||||
const mz_zip_array *pCentral_dir = &pState->m_central_dir;
|
||||
mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
|
||||
const uint32_t size = pZip->m_total_files;
|
||||
const mz_uint filename_len = (mz_uint)strlen(pFilename);
|
||||
const mz_uint32 size = pZip->m_total_files;
|
||||
const mz_uint32 filename_len = (mz_uint32)strlen(pFilename);
|
||||
|
||||
if (pIndex)
|
||||
*pIndex = 0;
|
||||
@ -1396,7 +1397,7 @@ static mz_bool mz_zip_locate_file_binary_search(mz_zip_archive *pZip, const char
|
||||
while (l <= h)
|
||||
{
|
||||
mz_int64 m = l + ((h - l) >> 1);
|
||||
uint32_t file_index = pIndices[(uint32_t)m];
|
||||
mz_uint32 file_index = pIndices[(mz_uint32)m];
|
||||
|
||||
int comp = mz_zip_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len);
|
||||
if (!comp)
|
||||
@ -1426,7 +1427,7 @@ int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const cha
|
||||
|
||||
mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *pIndex)
|
||||
{
|
||||
mz_uint file_index;
|
||||
mz_uint32 file_index;
|
||||
size_t name_len, comment_len;
|
||||
|
||||
if (pIndex)
|
||||
@ -1455,13 +1456,13 @@ mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, co
|
||||
for (file_index = 0; file_index < pZip->m_total_files; file_index++)
|
||||
{
|
||||
const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
|
||||
mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
mz_uint32 filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);
|
||||
const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
|
||||
if (filename_len < name_len)
|
||||
continue;
|
||||
if (comment_len)
|
||||
{
|
||||
mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);
|
||||
mz_uint32 file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);
|
||||
const char *pFile_comment = pFilename + filename_len + file_extra_len;
|
||||
if ((file_comment_len != comment_len) || (!mz_zip_string_equal(pComment, pFile_comment, file_comment_len, flags)))
|
||||
continue;
|
||||
@ -1489,7 +1490,7 @@ mz_bool mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, co
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_FILE_NOT_FOUND);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
|
||||
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint32 file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
|
||||
{
|
||||
int status = TINFL_STATUS_DONE;
|
||||
mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
|
||||
@ -1640,7 +1641,7 @@ mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const c
|
||||
return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags)
|
||||
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint32 file_index, void *pBuf, size_t buf_size, mz_uint flags)
|
||||
{
|
||||
return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0);
|
||||
}
|
||||
@ -1650,7 +1651,7 @@ mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFil
|
||||
return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0);
|
||||
}
|
||||
|
||||
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
|
||||
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint32 file_index, size_t *pSize, mz_uint flags)
|
||||
{
|
||||
mz_uint64 comp_size, uncomp_size, alloc_size;
|
||||
const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
|
||||
@ -1704,10 +1705,10 @@ void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFile
|
||||
return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
|
||||
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint32 file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
|
||||
{
|
||||
int status = TINFL_STATUS_DONE;
|
||||
mz_uint file_crc32 = MZ_CRC32_INIT;
|
||||
mz_uint32 file_crc32 = MZ_CRC32_INIT;
|
||||
mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
void *pRead_buf = NULL;
|
||||
@ -1911,7 +1912,7 @@ mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char
|
||||
return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags);
|
||||
}
|
||||
|
||||
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
|
||||
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint32 file_index, mz_uint flags)
|
||||
{
|
||||
mz_zip_reader_extract_iter_state *pState;
|
||||
mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
|
||||
@ -2217,7 +2218,7 @@ static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const voi
|
||||
return MZ_FWRITE(pBuf, 1, n, (MZ_FILE *)pOpaque);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
|
||||
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint32 file_index, const char *pDst_filename, mz_uint flags)
|
||||
{
|
||||
mz_bool status;
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
@ -2260,7 +2261,7 @@ mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pAr
|
||||
return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *pFile, mz_uint flags)
|
||||
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint32 file_index, MZ_FILE *pFile, mz_uint flags)
|
||||
{
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
|
||||
@ -2291,7 +2292,7 @@ static size_t mz_zip_compute_crc32_callback(void *pOpaque, mz_uint64 file_ofs, c
|
||||
return n;
|
||||
}
|
||||
|
||||
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags)
|
||||
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint32 file_index, mz_uint flags)
|
||||
{
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
mz_zip_internal_state *pState;
|
||||
@ -2305,7 +2306,7 @@ mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint f
|
||||
mz_uint64 local_header_comp_size, local_header_uncomp_size;
|
||||
mz_uint32 uncomp_crc32 = MZ_CRC32_INIT;
|
||||
mz_bool has_data_descriptor;
|
||||
mz_uint32 local_header_bit_flags;
|
||||
mz_uint local_header_bit_flags;
|
||||
|
||||
mz_zip_array file_data_array;
|
||||
mz_zip_array_init(&file_data_array, 1);
|
||||
@ -2500,7 +2501,7 @@ handle_failure:
|
||||
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags)
|
||||
{
|
||||
mz_zip_internal_state *pState;
|
||||
uint32_t i;
|
||||
mz_uint32 i;
|
||||
|
||||
if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (!pZip->m_pRead))
|
||||
return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
|
||||
@ -3122,7 +3123,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_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date,
|
||||
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_uint32 user_extra_data_len)
|
||||
{
|
||||
mz_zip_internal_state *pState = pZip->m_pState;
|
||||
mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;
|
||||
@ -3174,13 +3175,13 @@ static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
|
||||
return MZ_TRUE;
|
||||
}
|
||||
|
||||
static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
|
||||
static mz_uint32 mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
|
||||
{
|
||||
mz_uint32 n;
|
||||
if (!pZip->m_file_offset_alignment)
|
||||
return 0;
|
||||
n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
|
||||
return (mz_uint)((pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1));
|
||||
return (mz_uint32)((pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1));
|
||||
}
|
||||
|
||||
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n)
|
||||
@ -3207,10 +3208,10 @@ 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_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_uint32 user_extra_data_len, const char *user_extra_data_central, mz_uint32 user_extra_data_central_len)
|
||||
{
|
||||
mz_uint16 method = 0, dos_time = 0, dos_date = 0;
|
||||
mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
|
||||
mz_uint32 level, ext_attributes = 0, num_alignment_padding_bytes;
|
||||
mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0;
|
||||
size_t archive_name_size;
|
||||
mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
|
||||
@ -3492,10 +3493,10 @@ mz_bool mz_zip_writer_add_mem_ex_v2(mz_zip_archive *pZip, const char *pArchive_n
|
||||
|
||||
#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,
|
||||
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_uint32 user_extra_data_len, const char *user_extra_data_central, mz_uint32 user_extra_data_central_len)
|
||||
{
|
||||
mz_uint16 gen_flags = MZ_ZIP_LDH_BIT_FLAG_HAS_LOCATOR;
|
||||
mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
|
||||
mz_uint32 uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
|
||||
mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
|
||||
mz_uint64 local_dir_header_ofs, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = size_to_add, comp_size = 0;
|
||||
size_t archive_name_size;
|
||||
@ -3667,7 +3668,7 @@ mz_bool mz_zip_writer_add_cfile(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
{
|
||||
while (uncomp_remaining)
|
||||
{
|
||||
mz_uint n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
|
||||
mz_uint32 n = (mz_uint32)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
|
||||
if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
|
||||
{
|
||||
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
|
||||
@ -3823,7 +3824,7 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
}
|
||||
#endif /* #ifndef MINIZ_NO_STDIO */
|
||||
|
||||
static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, uint32_t ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start)
|
||||
static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext, mz_zip_archive *pZip, const mz_uint8 *pExt, mz_uint32 ext_len, mz_uint64 *pComp_size, mz_uint64 *pUncomp_size, mz_uint64 *pLocal_header_ofs, mz_uint32 *pDisk_start)
|
||||
{
|
||||
/* + 64 should be enough for any new zip64 data */
|
||||
if (!mz_zip_array_reserve(pZip, pNew_ext, ext_len + 64, MZ_FALSE))
|
||||
@ -3903,9 +3904,10 @@ static mz_bool mz_zip_writer_update_zip64_extension_block(mz_zip_array *pNew_ext
|
||||
}
|
||||
|
||||
/* TODO: This func is now pretty freakin complex due to zip64, split it up? */
|
||||
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index)
|
||||
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint32 src_file_index)
|
||||
{
|
||||
mz_uint n, bit_flags, num_alignment_padding_bytes, src_central_dir_following_data_size;
|
||||
mz_uint bit_flags;
|
||||
mz_uint32 n, num_alignment_padding_bytes, src_central_dir_following_data_size;
|
||||
mz_uint64 src_archive_bytes_remaining, local_dir_header_ofs;
|
||||
mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
|
||||
mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)];
|
||||
@ -4083,7 +4085,7 @@ mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *
|
||||
|
||||
while (src_archive_bytes_remaining)
|
||||
{
|
||||
n = (mz_uint)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining);
|
||||
n = (mz_uint32)MZ_MIN((mz_uint64)MZ_ZIP_MAX_IO_BUF_SIZE, src_archive_bytes_remaining);
|
||||
if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
|
||||
{
|
||||
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
|
||||
@ -4673,7 +4675,7 @@ size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip)
|
||||
return pZip->m_pState->m_central_dir.m_size;
|
||||
}
|
||||
|
||||
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
|
||||
mz_uint32 mz_zip_reader_get_num_files(mz_zip_archive *pZip)
|
||||
{
|
||||
return pZip ? pZip->m_total_files : 0;
|
||||
}
|
||||
@ -4707,9 +4709,9 @@ size_t mz_zip_read_archive_data(mz_zip_archive *pZip, mz_uint64 file_ofs, void *
|
||||
return pZip->m_pRead(pZip->m_pIO_opaque, file_ofs, pBuf, n);
|
||||
}
|
||||
|
||||
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
|
||||
mz_uint32 mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint32 file_index, char *pFilename, mz_uint32 filename_buf_size)
|
||||
{
|
||||
mz_uint n;
|
||||
mz_uint32 n;
|
||||
const mz_uint8 *p = mz_zip_get_cdh(pZip, file_index);
|
||||
if (!p)
|
||||
{
|
||||
@ -4728,7 +4730,7 @@ mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, cha
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
|
||||
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint32 file_index, mz_zip_archive_file_stat *pStat)
|
||||
{
|
||||
return mz_zip_file_stat_internal(pZip, file_index, mz_zip_get_cdh(pZip, file_index), pStat, NULL);
|
||||
}
|
||||
|
||||
42
miniz_zip.h
42
miniz_zip.h
@ -181,7 +181,7 @@ typedef struct
|
||||
|
||||
int status;
|
||||
#ifndef MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS
|
||||
mz_uint file_crc32;
|
||||
mz_uint32 file_crc32;
|
||||
#endif
|
||||
mz_uint64 read_buf_size, read_buf_ofs, read_buf_avail, comp_remaining, out_buf_ofs, cur_file_ofs;
|
||||
mz_zip_archive_file_stat file_stat;
|
||||
@ -228,7 +228,7 @@ mz_zip_mode mz_zip_get_mode(mz_zip_archive *pZip);
|
||||
mz_zip_type mz_zip_get_type(mz_zip_archive *pZip);
|
||||
|
||||
/* Returns the total number of files in the archive. */
|
||||
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
|
||||
mz_uint32 mz_zip_reader_get_num_files(mz_zip_archive *pZip);
|
||||
|
||||
mz_uint64 mz_zip_get_archive_size(mz_zip_archive *pZip);
|
||||
mz_uint64 mz_zip_get_archive_file_start_offset(mz_zip_archive *pZip);
|
||||
@ -253,17 +253,17 @@ mz_zip_error mz_zip_get_last_error(mz_zip_archive *pZip);
|
||||
const char *mz_zip_get_error_string(mz_zip_error mz_err);
|
||||
|
||||
/* MZ_TRUE if the archive file entry is a directory entry. */
|
||||
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
|
||||
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint32 file_index);
|
||||
|
||||
/* MZ_TRUE if the file is encrypted/strong encrypted. */
|
||||
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
|
||||
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint32 file_index);
|
||||
|
||||
/* MZ_TRUE if the compression method is supported, and the file is not encrypted, and the file is not a compressed patch file. */
|
||||
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint file_index);
|
||||
mz_bool mz_zip_reader_is_file_supported(mz_zip_archive *pZip, mz_uint32 file_index);
|
||||
|
||||
/* Retrieves the filename of an archive file entry. */
|
||||
/* Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename. */
|
||||
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
|
||||
mz_uint32 mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint32 file_index, char *pFilename, mz_uint32 filename_buf_size);
|
||||
|
||||
/* Attempts to locates a file in the archive's central directory. */
|
||||
/* Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH */
|
||||
@ -272,7 +272,7 @@ int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const cha
|
||||
int mz_zip_reader_locate_file_v2(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags, mz_uint32 *file_index);
|
||||
|
||||
/* Returns detailed information about an archive file entry. */
|
||||
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
|
||||
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint32 file_index, mz_zip_archive_file_stat *pStat);
|
||||
|
||||
/* MZ_TRUE if the file is in zip64 format. */
|
||||
/* A file is considered zip64 if it contained a zip64 end of central directory marker, or if it contained any zip64 extended file information fields in the central directory. */
|
||||
@ -284,25 +284,25 @@ size_t mz_zip_get_central_dir_size(mz_zip_archive *pZip);
|
||||
|
||||
/* Extracts a archive file to a memory buffer using no memory allocation. */
|
||||
/* There must be at least enough room on the stack to store the inflator's state (~34KB or so). */
|
||||
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
|
||||
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint32 file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
|
||||
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
|
||||
|
||||
/* Extracts a archive file to a memory buffer. */
|
||||
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint32 file_index, void *pBuf, size_t buf_size, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
|
||||
|
||||
/* Extracts a archive file to a dynamically allocated heap buffer. */
|
||||
/* The memory will be allocated via the mz_zip_archive's alloc/realloc functions. */
|
||||
/* Returns NULL and sets the last error on failure. */
|
||||
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
|
||||
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint32 file_index, size_t *pSize, mz_uint flags);
|
||||
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
|
||||
|
||||
/* Extracts a archive file using a callback function to output the file's data. */
|
||||
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint32 file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
|
||||
|
||||
/* Extract a file iteratively */
|
||||
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
|
||||
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_iter_new(mz_zip_archive *pZip, mz_uint32 file_index, mz_uint flags);
|
||||
mz_zip_reader_extract_iter_state* mz_zip_reader_extract_file_iter_new(mz_zip_archive *pZip, const char *pFilename, mz_uint flags);
|
||||
size_t mz_zip_reader_extract_iter_read(mz_zip_reader_extract_iter_state* pState, void* pvBuf, size_t buf_size);
|
||||
mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState);
|
||||
@ -310,18 +310,18 @@ mz_bool mz_zip_reader_extract_iter_free(mz_zip_reader_extract_iter_state* pState
|
||||
#ifndef MINIZ_NO_STDIO
|
||||
/* Extracts a archive file to a disk file and sets its last accessed and modified times. */
|
||||
/* This function only extracts files, not archive directory records. */
|
||||
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint32 file_index, const char *pDst_filename, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
|
||||
|
||||
/* Extracts a archive file starting at the current position in the destination FILE stream. */
|
||||
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint file_index, MZ_FILE *File, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_to_cfile(mz_zip_archive *pZip, mz_uint32 file_index, MZ_FILE *File, mz_uint flags);
|
||||
mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pArchive_filename, MZ_FILE *pFile, mz_uint flags);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* TODO */
|
||||
typedef void *mz_zip_streaming_extract_state_ptr;
|
||||
mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
|
||||
mz_zip_streaming_extract_state_ptr mz_zip_streaming_extract_begin(mz_zip_archive *pZip, mz_uint32 file_index, mz_uint flags);
|
||||
uint64_t mz_zip_streaming_extract_get_size(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
|
||||
uint64_t mz_zip_streaming_extract_get_cur_ofs(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState);
|
||||
mz_bool mz_zip_streaming_extract_seek(mz_zip_archive *pZip, mz_zip_streaming_extract_state_ptr pState, uint64_t new_ofs);
|
||||
@ -331,7 +331,7 @@ mz_bool mz_zip_reader_extract_file_to_cfile(mz_zip_archive *pZip, const char *pA
|
||||
|
||||
/* This function compares the archive's local headers, the optional local zip64 extended information block, and the optional descriptor following the compressed data vs. the data in the central directory. */
|
||||
/* It also validates that each file can be successfully uncompressed unless the MZ_ZIP_FLAG_VALIDATE_HEADERS_ONLY is specified. */
|
||||
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint file_index, mz_uint flags);
|
||||
mz_bool mz_zip_validate_file(mz_zip_archive *pZip, mz_uint32 file_index, mz_uint flags);
|
||||
|
||||
/* Validates an entire archive by calling mz_zip_validate_file() on each file. */
|
||||
mz_bool mz_zip_validate_archive(mz_zip_archive *pZip, mz_uint flags);
|
||||
@ -382,8 +382,8 @@ mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name
|
||||
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
|
||||
|
||||
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, const char *user_extra_data_local, mz_uint user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
|
||||
mz_uint64 uncomp_size, mz_uint32 uncomp_crc32, MZ_TIME_T *last_modified, const char *user_extra_data_local, mz_uint32 user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint32 user_extra_data_central_len);
|
||||
|
||||
#ifndef MINIZ_NO_STDIO
|
||||
/* Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive. */
|
||||
@ -392,13 +392,13 @@ mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name,
|
||||
|
||||
/* Like mz_zip_writer_add_file(), except the file data is read from the specified FILE stream. */
|
||||
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_local, mz_uint user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint user_extra_data_central_len);
|
||||
const MZ_TIME_T *pFile_time, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, const char *user_extra_data_local, mz_uint32 user_extra_data_local_len,
|
||||
const char *user_extra_data_central, mz_uint32 user_extra_data_central_len);
|
||||
#endif
|
||||
|
||||
/* Adds a file to an archive by fully cloning the data from another archive. */
|
||||
/* This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data (it may add or modify the zip64 local header extra data field), and the optional descriptor following the compressed data. */
|
||||
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint src_file_index);
|
||||
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint32 src_file_index);
|
||||
|
||||
/* Finalizes the archive by writing the central directory records followed by the end of central directory record. */
|
||||
/* After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end(). */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user