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

Method openFile

Engine/source/gui/editor/guiDebugger.cpp:304–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

guiDebugger.cppFile · 0.45

Calls 8

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

Tested by

no test coverage detected