MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / zipWriteInFileInZip

Function zipWriteInFileInZip

lib/QuaZip/quazip/zip.c:1455–1554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1453}
1454
1455extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned int len)
1456{
1457 zip64_internal* zi;
1458 int err=ZIP_OK;
1459
1460 if (file == NULL)
1461 return ZIP_PARAMERROR;
1462 zi = (zip64_internal*)file;
1463
1464 if (zi->in_opened_file_inzip == 0)
1465 return ZIP_PARAMERROR;
1466
1467 zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len);
1468
1469#ifdef HAVE_BZIP2
1470 if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
1471 {
1472 zi->ci.bstream.next_in = (void*)buf;
1473 zi->ci.bstream.avail_in = len;
1474 err = BZ_RUN_OK;
1475
1476 while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0))
1477 {
1478 if (zi->ci.bstream.avail_out == 0)
1479 {
1480 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1481 err = ZIP_ERRNO;
1482 zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1483 zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1484 }
1485
1486
1487 if(err != BZ_RUN_OK)
1488 break;
1489
1490 if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1491 {
1492 uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
1493/* uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */
1494 err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
1495
1496 zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
1497 }
1498 }
1499
1500 if(err == BZ_RUN_OK)
1501 err = ZIP_OK;
1502 }
1503 else
1504#endif
1505 {
1506 zi->ci.stream.next_in = (Bytef*)buf;
1507 zi->ci.stream.avail_in = len;
1508
1509 while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
1510 {
1511 if (zi->ci.stream.avail_out == 0)
1512 {

Callers 1

writeDataMethod · 0.85

Calls 2

zip64FlushWriteBufferFunction · 0.85
crc32Function · 0.50

Tested by

no test coverage detected