MCPcopy Create free account
hub / github.com/assimp/assimp / unzReadCurrentFile

Function unzReadCurrentFile

contrib/unzip/unzip.c:1552–1753  ·  view source on GitHub ↗

Read bytes from the current file. buf contain buffer where data must be copied len the size of buf. return the number of byte copied if some bytes are copied return 0 if the end of file was reached return <0 with error code if there is an error (UNZ_ERRNO for IO error, or zLib error for uncompress error) */

Source from the content-addressed store, hash-verified

1550 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
1551*/
1552extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) {
1553 int err=UNZ_OK;
1554 uInt iRead = 0;
1555 unz64_s* s;
1556 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1557 if (file==NULL)
1558 return UNZ_PARAMERROR;
1559 s=(unz64_s*)file;
1560 pfile_in_zip_read_info=s->pfile_in_zip_read;
1561
1562 if (pfile_in_zip_read_info==NULL)
1563 return UNZ_PARAMERROR;
1564
1565
1566 if (pfile_in_zip_read_info->read_buffer == NULL)
1567 return UNZ_END_OF_LIST_OF_FILE;
1568 if (len==0)
1569 return 0;
1570
1571 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1572
1573 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1574
1575 if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
1576 (!(pfile_in_zip_read_info->raw)))
1577 pfile_in_zip_read_info->stream.avail_out =
1578 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1579
1580 if ((len>pfile_in_zip_read_info->rest_read_compressed+
1581 pfile_in_zip_read_info->stream.avail_in) &&
1582 (pfile_in_zip_read_info->raw))
1583 pfile_in_zip_read_info->stream.avail_out =
1584 (uInt)pfile_in_zip_read_info->rest_read_compressed+
1585 pfile_in_zip_read_info->stream.avail_in;
1586
1587 while (pfile_in_zip_read_info->stream.avail_out>0)
1588 {
1589 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1590 (pfile_in_zip_read_info->rest_read_compressed>0))
1591 {
1592 uInt uReadThis = UNZ_BUFSIZE;
1593 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1594 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1595 if (uReadThis == 0)
1596 return UNZ_EOF;
1597 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1598 pfile_in_zip_read_info->filestream,
1599 pfile_in_zip_read_info->pos_in_zipfile +
1600 pfile_in_zip_read_info->byte_before_the_zipfile,
1601 ZLIB_FILEFUNC_SEEK_SET)!=0)
1602 return UNZ_ERRNO;
1603 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1604 pfile_in_zip_read_info->filestream,
1605 pfile_in_zip_read_info->read_buffer,
1606 uReadThis)!=uReadThis)
1607 return UNZ_ERRNO;
1608
1609

Callers 2

InternReadFileMethod · 0.50
ExtractMethod · 0.50

Calls 1

crc32Function · 0.85

Tested by

no test coverage detected