You are here

public function DrupalRemoteStreamWrapper::stream_read in Remote Stream Wrapper 7

Support for fread(), file_get_contents() etc.

Parameters

$count: Maximum number of bytes to be read.

Return value

The string that was read, or FALSE in case of an error.

Overrides StreamWrapperInterface::stream_read

See also

http://php.net/manual/en/streamwrapper.stream-read.php

File

./remote_stream_wrapper.inc, line 179

Class

DrupalRemoteStreamWrapper
Stream wrapper to support local files.

Code

public function stream_read($count) {
  if (is_string($this->stream_content)) {
    $remaining_chars = strlen($this->stream_content) - $this->stream_pointer;
    $number_to_read = min($count, $remaining_chars);
    if ($remaining_chars > 0) {
      $buffer = substr($this->stream_content, $this->stream_pointer, $number_to_read);
      $this->stream_pointer += $number_to_read;
      return $buffer;
    }
  }
  return FALSE;
}