MCPcopy Create free account
hub / github.com/MariaDB/server / zipWriteInFileInZip

Function zipWriteInFileInZip

storage/connect/zip.c:1648–1747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1646}
1647
1648extern int ZEXPORT zipWriteInFileInZip(zipFile file, const void* buf, unsigned int len) {
1649 zip64_internal* zi;
1650 int err=ZIP_OK;
1651
1652 if (file == NULL)
1653 return ZIP_PARAMERROR;
1654 zi = (zip64_internal*)file;
1655
1656 if (zi->in_opened_file_inzip == 0)
1657 return ZIP_PARAMERROR;
1658
1659 zi->ci.crc32 = crc32(zi->ci.crc32,buf,(uInt)len);
1660
1661#ifdef HAVE_BZIP2
1662 if(zi->ci.method == Z_BZIP2ED && (!zi->ci.raw))
1663 {
1664 zi->ci.bstream.next_in = (void*)buf;
1665 zi->ci.bstream.avail_in = len;
1666 err = BZ_RUN_OK;
1667
1668 while ((err==BZ_RUN_OK) && (zi->ci.bstream.avail_in>0))
1669 {
1670 if (zi->ci.bstream.avail_out == 0)
1671 {
1672 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1673 err = ZIP_ERRNO;
1674 zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1675 zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1676 }
1677
1678
1679 if(err != BZ_RUN_OK)
1680 break;
1681
1682 if ((zi->ci.method == Z_BZIP2ED) && (!zi->ci.raw))
1683 {
1684 uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
1685/* uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32; */
1686 err=BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
1687
1688 zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo) ;
1689 }
1690 }
1691
1692 if(err == BZ_RUN_OK)
1693 err = ZIP_OK;
1694 }
1695 else
1696#endif
1697 {
1698 zi->ci.stream.next_in = buf;
1699 zi->ci.stream.avail_in = len;
1700
1701 while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
1702 {
1703 if (zi->ci.stream.avail_out == 0)
1704 {
1705 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)

Callers 1

writeEntryMethod · 0.85

Calls 3

zip64FlushWriteBufferFunction · 0.85
deflateFunction · 0.85
crc32Function · 0.50

Tested by

no test coverage detected