protected function FileProfilerStorage::readLineFromFile

Reads a line in the file, ending with the current position.

This function automatically skips the empty lines and do not include the line return in result value.

Parameters

resource $file The file resource, with the pointer placed at the end of the line to read:

Return value

mixed A string representing the line or FALSE if beginning of file is reached

1 call to FileProfilerStorage::readLineFromFile()
FileProfilerStorage::find in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php
Finds profiler tokens for the given criteria.

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php, line 210

Class

FileProfilerStorage
Storage for profiler using files.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function readLineFromFile($file) {
  if (ftell($file) === 0) {
    return false;
  }
  fseek($file, -1, SEEK_CUR);
  $str = '';
  while (true) {
    $char = fgetc($file);
    if ($char === "\n") {

      // Leave the file with cursor before the line return
      fseek($file, -1, SEEK_CUR);
      break;
    }
    $str = $char . $str;
    if (ftell($file) === 1) {

      // All file is read, so we move cursor to the position 0
      fseek($file, -1, SEEK_CUR);
      break;
    }
    fseek($file, -2, SEEK_CUR);
  }
  return $str === '' ? $this
    ->readLineFromFile($file) : $str;
}