| 120 | } |
| 121 | |
| 122 | bool ResizeFilterStream::_read(const U32 in_numBytes, void* out_pBuffer) |
| 123 | { |
| 124 | AssertFatal(m_pStream != NULL, "Error, stream not attached"); |
| 125 | m_lastBytesRead = 0; |
| 126 | |
| 127 | if (in_numBytes == 0) |
| 128 | return true; |
| 129 | |
| 130 | AssertFatal(out_pBuffer != NULL, "Invalid output buffer"); |
| 131 | if (getStatus() == Closed) { |
| 132 | AssertFatal(false, "Attempted read from closed stream"); |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | U32 savePosition = m_pStream->getPosition(); |
| 137 | if (m_pStream->setPosition(m_startOffset + m_currOffset) == false) |
| 138 | return false; |
| 139 | |
| 140 | U32 actualSize = in_numBytes; |
| 141 | U32 position = m_startOffset + m_currOffset; |
| 142 | if (in_numBytes + position > m_startOffset + m_streamLen) |
| 143 | actualSize = m_streamLen - (position - m_startOffset); |
| 144 | |
| 145 | if (actualSize == 0) { |
| 146 | setStatus(EOS); |
| 147 | return false; |
| 148 | } |
| 149 | |
| 150 | bool success = m_pStream->read(actualSize, out_pBuffer); |
| 151 | m_currOffset += actualSize; |
| 152 | m_lastBytesRead = actualSize; |
| 153 | |
| 154 | setStatus(m_pStream->getStatus()); |
| 155 | |
| 156 | m_pStream->setPosition(savePosition); |
| 157 | return success; |
| 158 | } |
| 159 |
nothing calls this directly
no test coverage detected