コード例 #1
0
ファイル: ResourceStream.php プロジェクト: locphp/rsf
 public function seek($offset, $whence = SEEK_SET)
 {
     parent::seek($offset, $whence);
     if (fseek($this->stream, $offset, $whence) === -1) {
         throw new \Exception(sprintf('Unable to seek to stream position %d with whence %s', $offset, var_export($whence, true)));
     }
 }
コード例 #2
0
ファイル: StreamTest.php プロジェクト: innmind/filesystem
 /**
  * @expectedException Innmind\Filesystem\Exception\PositionNotSeekableException
  */
 public function testThrowWhenPositionNotSeekable()
 {
     $resource = fopen('php://temp', 'r+');
     fwrite($resource, 'Lorem ipsum dolor');
     $stream = new Stream($resource);
     $stream->seek(200);
 }
コード例 #3
0
 public function testOverwrite()
 {
     $s = new Stream();
     $s->open(STREAM_MODE_READWRITE);
     $s->writeLine('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur aliquam.');
     $s->seek(20);
     $s->writeLine('Lorem ipsum dolor sit amet.');
     $this->assertEquals($s->buffer, "Lorem ipsum dolor siLorem ipsum dolor sit amet.\ning elit. Curabitur aliquam.\n");
 }