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

Method setPosition

Engine/source/core/util/zip/zipSubStream.cpp:220–280  ·  view source on GitHub ↗

--------------------------------------

Source from the content-addressed store, hash-verified

218
219//--------------------------------------
220bool ZipSubRStream::setPosition(const U32 in_newPosition)
221{
222 AssertFatal(m_pStream != NULL, "Error, not attached");
223
224 if (in_newPosition == 0)
225 {
226 Stream* pStream = getStream();
227 U32 resetPosition = m_originalSlavePosition;
228 U32 uncompressedSize = m_uncompressedSize;
229 detachStream();
230 pStream->setPosition(resetPosition);
231 attachStream(pStream);
232 setUncompressedSize(uncompressedSize);
233 return true;
234 }
235 else
236 {
237 if (in_newPosition > m_uncompressedSize)
238 return false;
239
240 U32 newPosition = in_newPosition;
241 if (newPosition < m_currentPosition)
242 {
243 Stream* pStream = getStream();
244 U32 resetPosition = m_originalSlavePosition;
245 U32 uncompressedSize = m_uncompressedSize;
246 detachStream();
247 pStream->setPosition(resetPosition);
248 attachStream(pStream);
249 setUncompressedSize(uncompressedSize);
250 }
251 else
252 {
253 newPosition -= m_currentPosition;
254 }
255
256 bool bRet = true;
257 char *buffer = new char[2048];
258 while (newPosition >= 2048)
259 {
260 newPosition -= 2048;
261 if (!_read(2048,buffer))
262 {
263 bRet = false;
264 break;
265 }
266 };
267 if (bRet && newPosition > 0)
268 {
269 if (!_read(newPosition,buffer))
270 {
271 bRet = false;
272 };
273 };
274
275 delete [] buffer;
276
277 return bRet;

Callers 7

readExtraFieldsMethod · 0.45
readCentralDirectoryMethod · 0.45
copyFileToNewZipMethod · 0.45
openFileForReadMethod · 0.45
readMethod · 0.45
findInStreamMethod · 0.45
_finishMethod · 0.45

Calls 2

detachStreamFunction · 0.85
attachStreamFunction · 0.85

Tested by

no test coverage detected