MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / zipWriteInFileInZip

Function zipWriteInFileInZip

extlibs/minizip/src/zip.c:1388–1493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1386}
1387
1388extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len)
1389{
1390 zip64_internal* zi;
1391 int err = ZIP_OK;
1392
1393 if (file == NULL)
1394 return ZIP_PARAMERROR;
1395 zi = (zip64_internal*)file;
1396
1397 if (zi->in_opened_file_inzip == 0)
1398 return ZIP_PARAMERROR;
1399
1400 zi->ci.crc32 = crc32(zi->ci.crc32, buf, (uInt)len);
1401
1402#ifdef HAVE_BZIP2
1403 if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
1404 {
1405 zi->ci.bstream.next_in = (void*)buf;
1406 zi->ci.bstream.avail_in = len;
1407 err = BZ_RUN_OK;
1408
1409 while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0))
1410 {
1411 if (zi->ci.bstream.avail_out == 0)
1412 {
1413 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1414 err = ZIP_ERRNO;
1415 zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1416 zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1417 }
1418
1419
1420 if(err != BZ_RUN_OK)
1421 break;
1422
1423 if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1424 {
1425 uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
1426 // uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;
1427 err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
1428
1429 zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
1430 }
1431 }
1432
1433 if(err == BZ_RUN_OK)
1434 err = ZIP_OK;
1435 }
1436 else
1437#endif
1438 {
1439 zi->ci.stream.next_in = (Bytef*)buf;
1440 zi->ci.stream.avail_in = len;
1441
1442 while ((err == ZIP_OK) && (zi->ci.stream.avail_in > 0))
1443 {
1444 if (zi->ci.stream.avail_out == 0)
1445 {

Callers 1

zipper.cppFile · 0.85

Calls 3

crc32Function · 0.85
zip64FlushWriteBufferFunction · 0.85
deflateFunction · 0.85

Tested by

no test coverage detected