You are here

protected function ReplicateAdapter::ensureSeekable in Flysystem 7

Rewinds the stream, or returns the source stream if not seekable.

Parameters

resource $resource: The resource to rewind.

string $path: The path where the resource exists.

Return value

resource A stream set to position zero.

2 calls to ReplicateAdapter::ensureSeekable()
ReplicateAdapter::updateStream in src/Flysystem/Adapter/ReplicateAdapter.php
ReplicateAdapter::writeStream in src/Flysystem/Adapter/ReplicateAdapter.php

File

src/Flysystem/Adapter/ReplicateAdapter.php, line 65
Contains \Drupal\flysystem\Flysystem\Adapter\ReplicateAdapter.

Class

ReplicateAdapter
@todo Remove after https://github.com/thephpleague/flysystem-replicate-adapter/pull/5

Namespace

Drupal\flysystem\Flysystem\Adapter

Code

protected function ensureSeekable($resource, $path) {
  if (Util::isSeekableStream($resource) && rewind($resource)) {
    return $resource;
  }
  $stream = $this->source
    ->readStream($path);
  return $stream ? $stream['stream'] : FALSE;
}