public function S3fsStreamWrapper::dirname in S3 File System 7.2
Same name and namespace in other branches
- 7.3 S3fsStreamWrapper.inc \S3fsStreamWrapper::dirname()
- 7 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
File
- ./
S3fsStreamWrapper.inc, line 569 - 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;
}
$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}";
}