You are here

public function DrupalRemoteStreamWrapper::stream_stat in Remote Stream Wrapper 7

Support for fstat().

Return value

An array with file status, or FALSE in case of an error - see fstat() for a description of this array.

Overrides StreamWrapperInterface::stream_stat

See also

http://php.net/manual/en/streamwrapper.stream-stat.php

1 call to DrupalRemoteStreamWrapper::stream_stat()
DrupalRemoteStreamWrapper::url_stat in ./remote_stream_wrapper.inc
Support for stat().

File

./remote_stream_wrapper.inc, line 271

Class

DrupalRemoteStreamWrapper
Stream wrapper to support local files.

Code

public function stream_stat() {
  $stat = array();
  $request = drupal_http_request($this->uri, array(
    'method' => 'HEAD',
  ));
  if (empty($request->error)) {
    if (isset($request->headers['content-length'])) {
      $stat['size'] = $request->headers['content-length'];
    }
    elseif ($size = strlen($this
      ->getStreamContent())) {

      // If the HEAD request does not return a Content-Length header, fall
      // back to performing a full request of the file to determine its file
      // size.
      $stat['size'] = $size;
    }
  }
  return !empty($stat) ? $this
    ->getStat($stat) : FALSE;
}