You are here

public function SessionStreamWrapper::stream_seek in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php \Drupal\stream_wrapper_example\StreamWrapper\SessionStreamWrapper::stream_seek()

Seeks to specific location in a stream.

This method is called in response to fseek().

The read/write position of the stream should be updated according to the offset and whence.

Parameters

int $offset: The byte offset to seek to.

int $whence: Possible values:

  • SEEK_SET: Set position equal to offset bytes.
  • SEEK_CUR: Set position to current location plus offset.
  • SEEK_END: Set position to end-of-file plus offset.

Defaults to SEEK_SET.

Return value

bool TRUE if the position was updated, FALSE otherwise.

Overrides PhpStreamWrapperInterface::stream_seek

See also

http://php.net/manual/streamwrapper.stream-seek.php

File

modules/stream_wrapper_example/src/StreamWrapper/SessionStreamWrapper.php, line 516

Class

SessionStreamWrapper
Example stream wrapper class to handle session:// streams.

Namespace

Drupal\stream_wrapper_example\StreamWrapper

Code

public function stream_seek($offset, $whence = SEEK_SET) {

  // @codingStandardsIgnoreEnd
  if (strlen($this->sessionContent) >= $offset) {
    $this->streamPointer = $offset;
    return TRUE;
  }
  return FALSE;
}