protected function stream(FileInterface $file, Stream $dst)
 {
     $src = $this->createSourceStream($file);
     // always use reading only for the source
     $this->openStream($src, 'r');
     while (!$src->eof()) {
         $data = $src->read($this->bufferSize);
         $dst->write($data);
     }
     $dst->close();
     $src->close();
 }
 /**
  * @param \Gaufrette\Stream $stream
  */
 function it_should_cast_stream($stream)
 {
     $stream->cast(STREAM_CAST_FOR_SELECT)->willReturn('resource');
     $this->stream_open('gaufrette://some/filename', 'w+');
     $this->stream_cast(STREAM_CAST_FOR_SELECT)->shouldReturn('resource');
 }
Example #3
0
 /**
  * Copy stream to storage
  *
  * @param Stream $srcStream
  * @param string $destinationFileName
  */
 protected function copyStreamToStorage(Stream $srcStream, $destinationFileName)
 {
     $dstStream = $this->filesystem->createStream($destinationFileName);
     $srcStream->open(new StreamMode('rb+'));
     $dstStream->open(new StreamMode('wb+'));
     while (!$srcStream->eof()) {
         $dstStream->write($srcStream->read(self::READ_COUNT));
     }
     $dstStream->close();
     $srcStream->close();
 }
 /**
  * @param \Gaufrette\Stream $stream
  */
 function it_casts_stream($stream)
 {
     $stream->open(Argument::any())->willReturn(true);
     $stream->cast(STREAM_CAST_FOR_SELECT)->willReturn('resource');
     $this->stream_open('gaufrette://some/filename', 'w+');
     $this->stream_cast(STREAM_CAST_FOR_SELECT)->shouldReturn('resource');
 }