You are here

public function LocalStream::stream_metadata in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::stream_metadata()
  2. 9 core/lib/Drupal/Core/StreamWrapper/LocalStream.php \Drupal\Core\StreamWrapper\LocalStream::stream_metadata()

File

core/lib/Drupal/Core/StreamWrapper/LocalStream.php, line 244

Class

LocalStream
Defines a Drupal stream wrapper base class for local files.

Namespace

Drupal\Core\StreamWrapper

Code

public function stream_metadata($uri, $option, $value) {
  $target = $this
    ->getLocalPath($uri);
  $return = FALSE;
  switch ($option) {
    case STREAM_META_TOUCH:
      if (!empty($value)) {
        $return = touch($target, $value[0], $value[1]);
      }
      else {
        $return = touch($target);
      }
      break;
    case STREAM_META_OWNER_NAME:
    case STREAM_META_OWNER:
      $return = chown($target, $value);
      break;
    case STREAM_META_GROUP_NAME:
    case STREAM_META_GROUP:
      $return = chgrp($target, $value);
      break;
    case STREAM_META_ACCESS:
      $return = chmod($target, $value);
      break;
  }
  if ($return) {

    // For convenience clear the file status cache of the underlying file,
    // since metadata operations are often followed by file status checks.
    clearstatcache(TRUE, $target);
  }
  return $return;
}