public function AppendStream::seek in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/guzzlehttp/psr7/src/AppendStream.php \GuzzleHttp\Psr7\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 140
Class
- AppendStream
- Reads from multiple streams, one after the other.
Namespace
GuzzleHttp\Psr7Code
public function seek($offset, $whence = SEEK_SET) {
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;
}
}
}