MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / openFile

Method openFile

Engine/source/gui/editor/guiDebugger.cpp:298–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296}
297
298bool DbgFileView::openFile(const char *fileName)
299{
300 if ((! fileName) || (! fileName[0]))
301 return false;
302
303 StringTableEntry newFile = StringTable->insert(fileName);
304 if (mFileName == newFile)
305 return true;
306
307 void *data = NULL;
308 U32 dataSize = 0;
309 Torque::FS::ReadFile(fileName, data, dataSize, true);
310 if(data == NULL)
311 {
312 Con::printf("DbgFileView: unable to open file %s.", fileName);
313 return false;
314 }
315
316 //copy the file name
317 mFileName = newFile;
318
319 //clear the old mFileView
320 clear();
321 setSize(Point2I(1, 0));
322
323 //begin reading and parsing at each '\n'
324 char *parsePtr = (char *)data;
325 for(;;) {
326 char *tempPtr = dStrchr(parsePtr, '\n');
327 if(tempPtr)
328 addLine(parsePtr, tempPtr - parsePtr);
329 else if(parsePtr[0])
330 addLine(parsePtr, dStrlen(parsePtr));
331 if(!tempPtr)
332 break;
333 parsePtr = tempPtr + 1;
334 }
335 //delete the buffer
336 delete [] static_cast<char*>(data);
337
338 //set the file size
339 AdjustCellSize();
340 setSize(Point2I(1, mFileView.size()));
341
342 return true;
343}
344
345void DbgFileView::scrollToLine(S32 lineNumber)
346{

Callers 1

guiDebugger.cppFile · 0.45

Calls 8

ReadFileFunction · 0.85
printfFunction · 0.85
clearFunction · 0.50
Point2IClass · 0.50
dStrchrFunction · 0.50
dStrlenFunction · 0.50
insertMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected