public function S3fsStream::dirname in S3 File System 8.2
Same name and namespace in other branches
- 8.3 src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::dirname()
- 4.0.x src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::dirname()
Gets the name of the parent directory of a given path.
This method is usually accessed through \Drupal::service('file_system')->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 StreamWrapperInterface::dirname
See also
\Drupal::service('file_system')->dirname()
File
- src/
StreamWrapper/ S3fsStream.php, line 907
Class
- S3fsStream
- Defines a Drupal s3fs (s3fs://) stream wrapper class.
Namespace
Drupal\s3fs\StreamWrapperCode
public function dirname($uri = NULL) {
// $this->_debug("dirname($uri) called.");
if (!isset($uri)) {
$uri = $this->uri;
}
$scheme = \Drupal::service('file_system')
->uriScheme($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}";
}