MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / zipWriteInFileInZip

Function zipWriteInFileInZip

common/minizip/zip.c:1402–1507  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

mainFunction · 0.85
AddFromBufferMethod · 0.85
add_file_from_bufferFunction · 0.85

Calls 1

zip64FlushWriteBufferFunction · 0.85

Tested by

no test coverage detected