4
0
mirror of https://github.com/QuasarApp/zip.git synced 2025-05-01 22:59:34 +00:00

Fix warnings for MSC ()

* Include <io.h> for MSC

* Address  comments
This commit is contained in:
Kuba Podgórski 2020-12-22 13:25:28 +01:00 committed by GitHub
parent 903beb7d1c
commit 992106448d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 15 deletions

@ -5388,13 +5388,9 @@ mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip,
} else {
// Temporarily allocate a read buffer.
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&
(read_buf_size > 0x7FFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
#endif
return MZ_FALSE;
if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1,
(size_t)read_buf_size)))
return MZ_FALSE;
@ -5481,11 +5477,7 @@ void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index,
uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
#endif
return NULL;
if (NULL ==
(pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size)))
@ -5587,14 +5579,10 @@ mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip,
if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method)) {
// The file is stored or the caller has requested the compressed data.
if (pZip->m_pState->m_pMem) {
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) &&
(file_stat.m_comp_size > 0xFFFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) &&
(file_stat.m_comp_size > 0xFFFFFFFF))
#endif
return MZ_FALSE;
if (pCallback(pOpaque, out_buf_ofs, pRead_buf,
(size_t)file_stat.m_comp_size) != file_stat.m_comp_size)
status = TINFL_STATUS_FAILED;

@ -43,7 +43,9 @@
#include "zip.h"
#ifdef _MSC_VER
#define ftruncate(fd, sz) (-(_chsize_s((fd), (__int64)(sz)) != 0))
#include <io.h>
#define ftruncate(fd, sz) (-(_chsize_s((fd), (sz)) != 0))
#define fileno _fileno
#endif
@ -760,6 +762,7 @@ int zip_entry_fread(struct zip_t *zip, const char *filename) {
}
#if defined(_MSC_VER)
(void)xattr; // unused
#else
if (!mz_zip_reader_file_stat(pzip, idx, &info)) {
// Cannot get information about zip archive;
@ -988,6 +991,7 @@ static int extract(mz_zip_archive *zip_archive, const char *dir,
}
#if defined(_MSC_VER)
(void)xattr; // unused
#else
xattr = (info.m_external_attr >> 16) & 0xFFFF;
if (xattr > 0) {