| 729 | } |
| 730 | |
| 731 | void ZlibDecompressionStream::NextDecompress(const void** data, int* size, size_t availableSize) { |
| 732 | zstream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer)); |
| 733 | zstream_.avail_in = static_cast<uInt>(availableSize); |
| 734 | outputBuffer = outputDataBuffer.data(); |
| 735 | zstream_.next_out = reinterpret_cast<Bytef*>(const_cast<char*>(outputBuffer)); |
| 736 | zstream_.avail_out = static_cast<uInt>(outputDataBuffer.capacity()); |
| 737 | if (inflateReset(&zstream_) != Z_OK) { |
| 738 | throw CompressionError( |
| 739 | "Bad inflateReset in " |
| 740 | "ZlibDecompressionStream::NextDecompress"); |
| 741 | } |
| 742 | int64_t result; |
| 743 | do { |
| 744 | result = inflate(&zstream_, availableSize == remainingLength ? Z_FINISH : Z_SYNC_FLUSH); |
| 745 | switch (result) { |
| 746 | case Z_OK: |
| 747 | remainingLength -= availableSize; |
| 748 | inputBuffer += availableSize; |
| 749 | readBuffer(true); |
| 750 | availableSize = |
| 751 | std::min(static_cast<size_t>(inputBufferEnd - inputBuffer), remainingLength); |
| 752 | zstream_.next_in = reinterpret_cast<Bytef*>(const_cast<char*>(inputBuffer)); |
| 753 | zstream_.avail_in = static_cast<uInt>(availableSize); |
| 754 | break; |
| 755 | case Z_STREAM_END: |
| 756 | break; |
| 757 | case Z_BUF_ERROR: |
| 758 | throw CompressionError( |
| 759 | "Buffer error in " |
| 760 | "ZlibDecompressionStream::NextDecompress"); |
| 761 | case Z_DATA_ERROR: |
| 762 | throw CompressionError( |
| 763 | "Data error in " |
| 764 | "ZlibDecompressionStream::NextDecompress"); |
| 765 | case Z_STREAM_ERROR: |
| 766 | throw CompressionError( |
| 767 | "Stream error in " |
| 768 | "ZlibDecompressionStream::NextDecompress"); |
| 769 | default: |
| 770 | throw CompressionError( |
| 771 | "Unknown error in " |
| 772 | "ZlibDecompressionStream::NextDecompress"); |
| 773 | } |
| 774 | } while (result != Z_STREAM_END); |
| 775 | *size = static_cast<int>(outputDataBuffer.capacity() - zstream_.avail_out); |
| 776 | *data = outputBuffer; |
| 777 | outputBufferLength = 0; |
| 778 | outputBuffer += *size; |
| 779 | inputBuffer += availableSize; |
| 780 | remainingLength -= availableSize; |
| 781 | } |
| 782 | |
| 783 | std::string ZlibDecompressionStream::getName() const { |
| 784 | std::ostringstream result; |
nothing calls this directly
no test coverage detected