You are here

protected function AmazonS3StreamWrapper::_stat in AmazonS3 7

Get file status.

Return value

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

See also

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

2 calls to AmazonS3StreamWrapper::_stat()
AmazonS3StreamWrapper::stream_stat in ./AmazonS3StreamWrapper.inc
Support for fstat().
AmazonS3StreamWrapper::url_stat in ./AmazonS3StreamWrapper.inc
Support for stat().

File

./AmazonS3StreamWrapper.inc, line 1140
Drupal stream wrapper implementation for Amazon S3

Class

AmazonS3StreamWrapper
@file Drupal stream wrapper implementation for Amazon S3

Code

protected function _stat($uri = NULL) {
  if (!isset($uri)) {
    $uri = $this->uri;
  }
  $metadata = $this
    ->_amazons3_get_object($uri, $this->caching);
  if ($metadata) {
    $stat = array();
    $stat[0] = $stat['dev'] = 0;
    $stat[1] = $stat['ino'] = 0;
    $stat[2] = $stat['mode'] = $metadata['mode'];
    $stat[3] = $stat['nlink'] = 0;
    $stat[4] = $stat['uid'] = 0;
    $stat[5] = $stat['gid'] = 0;
    $stat[6] = $stat['rdev'] = 0;
    $stat[7] = $stat['size'] = 0;
    $stat[8] = $stat['atime'] = 0;
    $stat[9] = $stat['mtime'] = 0;
    $stat[10] = $stat['ctime'] = 0;
    $stat[11] = $stat['blksize'] = 0;
    $stat[12] = $stat['blocks'] = 0;
    if (!$metadata['dir']) {
      if (!isset($metadata['uid']) || !isset($metadata['filesize']) || !isset($metadata['timestamp'])) {
        return FALSE;
      }
      else {
        $stat[4] = $stat['uid'] = $metadata['uid'];
        $stat[7] = $stat['size'] = $metadata['filesize'];
        $stat[8] = $stat['atime'] = $metadata['timestamp'];
        $stat[9] = $stat['mtime'] = $metadata['timestamp'];
        $stat[10] = $stat['ctime'] = $metadata['timestamp'];
      }
    }
    return $stat;
  }
  return FALSE;
}