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

Method peekLine

Engine/source/core/fileObject.cpp:180–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void FileObject::peekLine( S32 peekLineOffset, U8* line, S32 length )
181{
182 if(!mFileBuffer)
183 {
184 line[0] = '\0';
185 return;
186 }
187
188 // Copy the line into the buffer. We can't do this like readLine because
189 // we can't modify the file buffer.
190 S32 i = 0;
191 U32 tokPos = mCurPos;
192 S32 lineOffset = 0;
193
194 //Lets push our tokPos up until we've offset the requested number of lines
195 while (lineOffset < peekLineOffset && tokPos <= mBufferSize)
196 {
197 if (mFileBuffer[tokPos] == '\r')
198 {
199 tokPos++;
200 if (mFileBuffer[tokPos] == '\n')
201 tokPos++;
202 lineOffset++;
203 continue;
204 }
205
206 if (mFileBuffer[tokPos] == '\n')
207 {
208 tokPos++;
209 lineOffset++;
210 continue;
211 }
212
213 tokPos++;
214 }
215
216 //now peek that line, then return the results
217 while( ( tokPos != mBufferSize ) && ( mFileBuffer[tokPos] != '\r' ) && ( mFileBuffer[tokPos] != '\n' ) && ( i < ( length - 1 ) ) )
218 line[i++] = mFileBuffer[tokPos++];
219
220 line[i++] = '\0';
221
222 //if( i == length )
223 //Con::warnf( "FileObject::peekLine - The line contents could not fit in the buffer (size %d). Truncating.", length );
224}
225
226void FileObject::writeLine(const U8 *line)
227{

Callers 1

fileObject.cppFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected