Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AppendStream.php

function AppendStream::seek

Attempts to seek to the given position. Only supports SEEK_SET.

Overrides StreamInterface::seek

1 call to AppendStream::seek()
AppendStream::rewind in vendor/guzzlehttp/psr7/src/AppendStream.php
Seek to the beginning of the stream.

File

vendor/guzzlehttp/psr7/src/AppendStream.php, line 156

Class

AppendStream
Reads from multiple streams, one after the other.

Namespace

GuzzleHttp\Psr7

Code

public function seek($offset, $whence = SEEK_SET) : void {
    if (!$this->seekable) {
        throw new \RuntimeException('This AppendStream is not seekable');
    }
    elseif ($whence !== SEEK_SET) {
        throw new \RuntimeException('The AppendStream can only seek with SEEK_SET');
    }
    $this->pos = $this->current = 0;
    // Rewind each stream
    foreach ($this->streams as $i => $stream) {
        try {
            $stream->rewind();
        } catch (\Exception $e) {
            throw new \RuntimeException('Unable to seek stream ' . $i . ' of the AppendStream', 0, $e);
        }
    }
    // Seek to the actual position by reading from each stream
    while ($this->pos < $offset && !$this->eof()) {
        $result = $this->read(min(8096, $offset - $this->pos));
        if ($result === '') {
            break;
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal