MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _read

Method _read

Engine/source/core/resizeStream.cpp:122–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122bool 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

Callers

nothing calls this directly

Calls 4

getPositionMethod · 0.45
setPositionMethod · 0.45
readMethod · 0.45
getStatusMethod · 0.45

Tested by

no test coverage detected