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

Function unzReadCurrentFile

common/minizip/unzip.c:1684–1883  ·  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 somes 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

1682 (UNZ_ERRNO for IO error, or zLib error for uncompress error)
1683*/
1684extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
1685{
1686 int err=UNZ_OK;
1687 uInt iRead = 0;
1688 unz64_s* s;
1689 file_in_zip64_read_info_s* pfile_in_zip_read_info;
1690 if (file==NULL)
1691 return UNZ_PARAMERROR;
1692 s=(unz64_s*)file;
1693 pfile_in_zip_read_info=s->pfile_in_zip_read;
1694
1695 if (pfile_in_zip_read_info==NULL)
1696 return UNZ_PARAMERROR;
1697
1698
1699 if (pfile_in_zip_read_info->read_buffer == NULL)
1700 return UNZ_END_OF_LIST_OF_FILE;
1701 if (len==0)
1702 return 0;
1703
1704 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf;
1705
1706 pfile_in_zip_read_info->stream.avail_out = (uInt)len;
1707
1708 if ((len>pfile_in_zip_read_info->rest_read_uncompressed) &&
1709 (!(pfile_in_zip_read_info->raw)))
1710 pfile_in_zip_read_info->stream.avail_out =
1711 (uInt)pfile_in_zip_read_info->rest_read_uncompressed;
1712
1713 if ((len>pfile_in_zip_read_info->rest_read_compressed+
1714 pfile_in_zip_read_info->stream.avail_in) &&
1715 (pfile_in_zip_read_info->raw))
1716 pfile_in_zip_read_info->stream.avail_out =
1717 (uInt)pfile_in_zip_read_info->rest_read_compressed+
1718 pfile_in_zip_read_info->stream.avail_in;
1719
1720 while (pfile_in_zip_read_info->stream.avail_out>0)
1721 {
1722 if ((pfile_in_zip_read_info->stream.avail_in==0) &&
1723 (pfile_in_zip_read_info->rest_read_compressed>0))
1724 {
1725 uInt uReadThis = UNZ_BUFSIZE;
1726 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
1727 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed;
1728 if (uReadThis == 0)
1729 return UNZ_EOF;
1730 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc,
1731 pfile_in_zip_read_info->filestream,
1732 pfile_in_zip_read_info->pos_in_zipfile +
1733 pfile_in_zip_read_info->byte_before_the_zipfile,
1734 ZLIB_FILEFUNC_SEEK_SET)!=0)
1735 return UNZ_ERRNO;
1736 if (ZREAD64(pfile_in_zip_read_info->z_filefunc,
1737 pfile_in_zip_read_info->filestream,
1738 pfile_in_zip_read_info->read_buffer,
1739 uReadThis)!=uReadThis)
1740 return UNZ_ERRNO;
1741

Callers 10

do_extract_currentfileFunction · 0.85
GetInnterFileDataMethod · 0.85
receive_dataFunction · 0.85
sr_new_virtual_deviceFunction · 0.85
receive_data_dsoFunction · 0.85
receive_data_analogFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected