Phly\Http\Stream::seek PHP 메소드

seek() 공개 메소드

public seek ( $offset, $whence = SEEK_SET )
    public function seek($offset, $whence = SEEK_SET)
    {
        if (!$this->resource) {
            throw new RuntimeException('No resource available; cannot seek position');
        }
        if (!$this->isSeekable()) {
            throw new RuntimeException('Stream is not seekable');
        }
        $result = fseek($this->resource, $offset, $whence);
        if (0 !== $result) {
            throw new RuntimeException('Error seeking within stream');
        }
        return true;
    }

Usage Example

예제 #1
0
파일: StreamTest.php 프로젝트: phly/http
 public function testSeekRaisesExceptionWhenStreamIsDetached()
 {
     $this->tmpnam = tempnam(sys_get_temp_dir(), 'phly');
     file_put_contents($this->tmpnam, 'FOO BAR');
     $resource = fopen($this->tmpnam, 'wb+');
     $stream = new Stream($resource);
     $stream->detach();
     $this->setExpectedException('RuntimeException', 'No resource');
     $stream->seek(2);
 }
All Usage Examples Of Phly\Http\Stream::seek