public function Stream::getSize

Get the size of the stream if able

Return value

int|bool

Overrides StreamInterface::getSize

1 call to Stream::getSize()
EntityBody::getContentLength in drupal/core/vendor/guzzle/http/Guzzle/Http/EntityBody.php
Get the Content-Length of the entity body if possible (alias of getSize)

File

drupal/core/vendor/guzzle/stream/Guzzle/Stream/Stream.php, line 185

Class

Stream
PHP stream implementation

Namespace

Guzzle\Stream

Code

public function getSize() {
  if ($this->size !== null) {
    return $this->size;
  }

  // If the stream is a file based stream and local, then check the filesize
  if ($this
    ->isLocal() && $this
    ->getWrapper() == 'plainfile' && $this
    ->getUri() && file_exists($this
    ->getUri())) {
    return filesize($this
      ->getUri());
  }

  // Only get the size based on the content if the the stream is readable and seekable
  if (!$this->cache[self::IS_READABLE] || !$this->cache[self::SEEKABLE]) {
    return false;
  }
  else {
    $pos = $this
      ->ftell();
    $this->size = strlen((string) $this);
    $this
      ->seek($pos);
    return $this->size;
  }
}