MCPcopy Create free account
hub / github.com/anjo76/angelscript / ReadLine

Method ReadLine

sdk/add_on/scriptfile/scriptfile.cpp:398–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396}
397
398string CScriptFile::ReadLine()
399{
400 if( file == 0 )
401 return "";
402
403 // Read until the first new-line character
404 string str;
405 char buf[256];
406
407 do
408 {
409 // Get the current position so we can determine how many characters were read
410 int start = ftell(file);
411
412 // Set the last byte to something different that 0, so that we can check if the buffer was filled up
413 buf[255] = 1;
414
415 // Read the line (or first 255 characters, which ever comes first)
416 char *r = fgets(buf, 256, file);
417 if( r == 0 ) break;
418
419 // Get the position after the read
420 int end = ftell(file);
421
422 // Add the read characters to the output buffer
423 str.append(buf, end-start);
424 }
425 while( !feof(file) && buf[255] == 0 && buf[254] != '\n' );
426
427 return str;
428}
429
430asINT64 CScriptFile::ReadInt(asUINT bytes)
431{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected