Close the file in zip opened with unzOpenCurrentFile Return UNZ_CRCERROR if all the file was read but the CRC is not good */
| 1994 | Return UNZ_CRCERROR if all the file was read but the CRC is not good |
| 1995 | */ |
| 1996 | extern int ZEXPORT unzCloseCurrentFile(unzFile file) |
| 1997 | { |
| 1998 | int err = UNZ_OK; |
| 1999 | |
| 2000 | unz64_s* s; |
| 2001 | file_in_zip64_read_info_s* pfile_in_zip_read_info; |
| 2002 | if (file == NULL) |
| 2003 | return UNZ_PARAMERROR; |
| 2004 | s = (unz64_s*)file; |
| 2005 | pfile_in_zip_read_info = s->pfile_in_zip_read; |
| 2006 | |
| 2007 | if (pfile_in_zip_read_info == NULL) |
| 2008 | return UNZ_PARAMERROR; |
| 2009 | |
| 2010 | |
| 2011 | if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && |
| 2012 | (!pfile_in_zip_read_info->raw)) |
| 2013 | { |
| 2014 | if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
| 2015 | err = UNZ_CRCERROR; |
| 2016 | } |
| 2017 | |
| 2018 | |
| 2019 | TRYFREE(pfile_in_zip_read_info->read_buffer); |
| 2020 | pfile_in_zip_read_info->read_buffer = NULL; |
| 2021 | if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) |
| 2022 | inflateEnd(&pfile_in_zip_read_info->stream); |
| 2023 | #ifdef HAVE_BZIP2 |
| 2024 | else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) |
| 2025 | BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); |
| 2026 | #endif |
| 2027 | |
| 2028 | |
| 2029 | pfile_in_zip_read_info->stream_initialised = 0; |
| 2030 | TRYFREE(pfile_in_zip_read_info); |
| 2031 | |
| 2032 | s->pfile_in_zip_read = NULL; |
| 2033 | |
| 2034 | return err; |
| 2035 | } |
| 2036 | |
| 2037 | |
| 2038 | /* |
no outgoing calls
no test coverage detected