MCPcopy Create free account
hub / github.com/TheOfficialFloW/VitaShell / zipWriteInFileInZip

Function zipWriteInFileInZip

minizip/zip.c:1482–1575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1480}
1481
1482extern int ZEXPORT zipWriteInFileInZip(zipFile file,const void* buf,unsigned int len)
1483{
1484 zip64_internal* zi;
1485 int err = ZIP_OK;
1486
1487 if (file == NULL)
1488 return ZIP_PARAMERROR;
1489 zi = (zip64_internal*)file;
1490
1491 if (zi->in_opened_file_inzip == 0)
1492 return ZIP_PARAMERROR;
1493
1494 zi->ci.crc32 = crc32(zi->ci.crc32, buf, (uInt)len);
1495
1496#ifdef HAVE_BZIP2
1497 if ((zi->ci.compression_method == Z_BZIP2ED) && (!zi->ci.raw))
1498 {
1499 zi->ci.bstream.next_in = (void*)buf;
1500 zi->ci.bstream.avail_in = len;
1501 err = BZ_RUN_OK;
1502
1503 while ((err == BZ_RUN_OK) && (zi->ci.bstream.avail_in > 0))
1504 {
1505 if (zi->ci.bstream.avail_out == 0)
1506 {
1507 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1508 err = ZIP_ERRNO;
1509 zi->ci.bstream.avail_out = (uInt)Z_BUFSIZE;
1510 zi->ci.bstream.next_out = (char*)zi->ci.buffered_data;
1511 }
1512 else
1513 {
1514 uLong uTotalOutBefore_lo = zi->ci.bstream.total_out_lo32;
1515 uLong uTotalOutBefore_hi = zi->ci.bstream.total_out_hi32;
1516
1517 err = BZ2_bzCompress(&zi->ci.bstream, BZ_RUN);
1518
1519 zi->ci.pos_in_buffered_data += (uInt)(zi->ci.bstream.total_out_lo32 - uTotalOutBefore_lo);
1520 }
1521 }
1522
1523 if (err == BZ_RUN_OK)
1524 err = ZIP_OK;
1525 }
1526 else
1527#endif
1528 {
1529 zi->ci.stream.next_in = (Bytef*)buf;
1530 zi->ci.stream.avail_in = len;
1531
1532 while ((err == ZIP_OK) && (zi->ci.stream.avail_in > 0))
1533 {
1534 if (zi->ci.stream.avail_out == 0)
1535 {
1536 if (zip64FlushWriteBuffer(zi) == ZIP_ERRNO)
1537 err = ZIP_ERRNO;
1538 zi->ci.stream.avail_out = (uInt)Z_BUFSIZE;
1539 zi->ci.stream.next_out = zi->ci.buffered_data;

Callers 1

zipAddFileFunction · 0.85

Calls 1

zip64FlushWriteBufferFunction · 0.85

Tested by

no test coverage detected