Использование minizip с таким кодом должно работать на Windows.
#define USEWIN32IOAPI
#include <zip.h>
#include <unzip.h>
#include <iowin32.h>
int toZip(const wchar_t* zipfile, const char* nameInZip, void* buf, size_t buf_size)
{
zlib_filefunc64_def ffunc;
fill_win32_filefunc64W(&ffunc);
zipFile zf = zipOpen2_64(zipfile, APPEND_STATUS_CREATE, NULL,&ffunc);
if(0 == zf) {
return -1;
}
zip_fileinfo zi;
zi.tmz_date.tm_sec = zi.tmz_date.tm_min = zi.tmz_date.tm_hour =
zi.tmz_date.tm_mday = zi.tmz_date.tm_mon = zi.tmz_date.tm_year = 0;
zi.dosDate = 0;
zi.internal_fa = 0;
zi.external_fa = 0;
zi.dosDate = 0; // no date
int zip64 = 1; // always zip64
unsigned long crcFile=0;
int opt_compress_level(Z_DEFAULT_COMPRESSION);
char* password = 0;
int err = zipOpenNewFileInZip3_64(zf,nameInZip,&zi,
NULL,0,NULL,0,NULL,
(opt_compress_level != 0) ? Z_DEFLATED : 0,
opt_compress_level,0,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,
password,crcFile, zip64);
if (ZIP_OK == err) {
err |= zipWriteInFileInZip (zf,buf,buf_size);
err |= zipCloseFileInZip(zf);
}
err |= zipClose(zf,NULL)
return err;
}