You are here

public function StreamWrapper::dirname in AmazonS3 7.2

File

src/StreamWrapper.php, line 316
Drupal stream wrapper implementation for Amazon S3

Class

StreamWrapper
@file Drupal stream wrapper implementation for Amazon S3

Namespace

Drupal\amazons3

Code

public function dirname($uri = NULL) {

  // drupal_dirname() doesn't call setUri() before calling. That lead our URI
  // to be stuck at the default 's3://'' that is set by
  // file_stream_wrapper_get_instance_by_scheme().
  if ($uri) {
    $this
      ->setUri($uri);
  }
  $s3url = S3Url::factory($uri, $this->config);
  $s3url
    ->normalizePath();
  $pathSegments = $s3url
    ->getPathSegments();
  array_pop($pathSegments);
  $s3url
    ->setPath($pathSegments);
  return trim((string) $s3url, '/');
}