Protobuf\Stream::seek PHP Method

seek() public method

Seek to a position in the stream
public seek ( integer $offset, integer $whence = SEEK_SET )
$offset integer
$whence integer
    public function seek($offset, $whence = SEEK_SET)
    {
        if (fseek($this->stream, $offset, $whence) !== 0) {
            throw new RuntimeException('Unable to seek stream position to ' . $offset);
        }
    }

Usage Example

Example #1
0
 /**
  * Encode a stream of bytes.
  *
  * @param \Protobuf\Stream $stream
  * @param \Protobuf\Stream $value
  */
 public function writeByteStream(Stream $stream, Stream $value)
 {
     $length = $value->getSize();
     $value->seek(0);
     $this->writeVarint($stream, $length);
     $stream->writeStream($value, $length);
 }
All Usage Examples Of Protobuf\Stream::seek