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

Method setPosition

Engine/source/core/stream/fileStream.cpp:78–116  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

76
77//-----------------------------------------------------------------------------
78bool FileStream::setPosition(const U32 i_newPosition)
79{
80 AssertFatal(0 != mStreamCaps, "FileStream::setPosition: the stream isn't open");
81 AssertFatal(hasCapability(StreamPosition), "FileStream::setPosition: lacks positioning capability");
82
83 // if the buffer is valid, test the new position against the bounds of the buffer
84 if ((BUFFER_INVALID != mBuffHead) && (i_newPosition >= mBuffHead) && (i_newPosition <= mBuffTail))
85 {
86 // set the position and return
87 mBuffPos = i_newPosition;
88
89 // FIXME [tom, 9/5/2006] This needs to be checked. Basically, when seeking within
90 // the buffer, if the stream has an EOS status before the seek then if you try to
91 // read immediately after seeking, you'll incorrectly get an EOS.
92 //
93 // I am not 100% sure if this fix is correct, but it seems to be working for the undo system.
94 if(mBuffPos < mBuffTail)
95 Stream::setStatus(Ok);
96
97 return(true);
98 }
99 // otherwise the new position lies in some block not in memory
100 else
101 {
102 if (mDirty)
103 flush();
104
105 clearBuffer();
106
107 mFile->setPosition(i_newPosition, Torque::FS::File::Begin);
108
109 setStatus();
110
111 if (mFile->getStatus() == Torque::FS::FileNode::EndOfFile)
112 mEOF = true;
113
114 return(Ok == getStatus() || EOS == getStatus());
115 }
116}
117
118//-----------------------------------------------------------------------------
119U32 FileStream::getStreamSize()

Callers 3

flushMethod · 0.45
fillBufferMethod · 0.45
cloneMethod · 0.45

Calls 1

getStatusMethod · 0.45

Tested by

no test coverage detected