You are here

public function S3fsStreamWrapper::dirname in S3 File System 7

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

Gets the name of the directory from 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 A string containing the directory name, or FALSE if not applicable.

Overrides DrupalStreamWrapperInterface::dirname

See also

drupal_dirname()

1 call to S3fsStreamWrapper::dirname()
S3fsStreamWrapper::_write_cache in ./S3fsStreamWrapper.inc
Write an object's (and its ancestor folders') metadata to the cache.

File

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

Class

S3fsStreamWrapper
The stream wrapper class.

Code

public function dirname($uri = NULL) {
  $this
    ->_debug("dirname({$uri}) called.");
  if (!isset($uri)) {
    $uri = $this->uri;
  }
  $target = $this
    ->getTarget($uri);
  $dirname = dirname($target);

  // When the dirname() call above is given 's3://', it returns '.'.
  // But 's3://.' is invalid, so we convert it to '' to get "s3://".
  if ($dirname == '.') {
    $dirname = '';
  }
  return "s3://{$dirname}";
}