You are here

public function S3fsStreamWrapper::dirname in S3 File System 7.3

Same name and namespace in other branches
  1. 7 S3fsStreamWrapper.inc \S3fsStreamWrapper::dirname()
  2. 7.2 S3fsStreamWrapper.inc \S3fsStreamWrapper::dirname()

Gets the name of the parent directory of a given path.

This method is usually accessed through drupal_dirname(), which wraps around the normal PHP dirname() function, since it doesn't support stream wrappers.

Parameters

string $uri: An optional URI.

Return value

string The directory name, or FALSE if not applicable.

Overrides DrupalStreamWrapperInterface::dirname

See also

drupal_dirname()

File

./S3fsStreamWrapper.inc, line 594
Drupal stream wrapper implementation for S3 File System.

Class

S3fsStreamWrapper
The stream wrapper class.

Code

public function dirname($uri = NULL) {
  if (!isset($uri)) {
    $uri = $this->uri;
  }
  $scheme = file_uri_scheme($uri);
  $dirname = dirname(file_uri_target($uri));

  // When the dirname() call above is given '$scheme://', it returns '.'.
  // But '$scheme://.' is an invalid uri, so we return "$scheme://" instead.
  if ($dirname == '.') {
    $dirname = '';
  }
  return "{$scheme}://{$dirname}";
}