You are here

public function Stream::seek in Lockr 7.3

Seek to a position in the stream.

@link http://www.php.net/manual/en/function.fseek.php

Parameters

int $offset Stream offset:

int $whence Specifies how the cursor position will be calculated: based on the seek offset. Valid values are identical to the built-in PHP $whence values for `fseek()`. SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.

Throws

\RuntimeException on failure.

Overrides StreamInterface::seek

2 calls to Stream::seek()
Stream::rewind in vendor/guzzlehttp/psr7/src/Stream.php
Seek to the beginning of the stream.
Stream::__toString in vendor/guzzlehttp/psr7/src/Stream.php
Reads all data from the stream into a string, from the beginning to end.

File

vendor/guzzlehttp/psr7/src/Stream.php, line 198

Class

Stream
PHP stream implementation.

Namespace

GuzzleHttp\Psr7

Code

public function seek($offset, $whence = SEEK_SET) {
  if (!isset($this->stream)) {
    throw new \RuntimeException('Stream is detached');
  }
  if (!$this->seekable) {
    throw new \RuntimeException('Stream is not seekable');
  }
  if (fseek($this->stream, $offset, $whence) === -1) {
    throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . var_export($whence, true));
  }
}