public function S3fsStream::dirname in S3 File System 4.0.x
Same name and namespace in other branches
- 8.3 src/StreamWrapper/S3fsStream.php \Drupal\s3fs\StreamWrapper\S3fsStream::dirname()
- 8.2 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 931
Class
- S3fsStream
- Defines a Drupal s3 (s3://) stream wrapper class.
Namespace
Drupal\s3fs\StreamWrapperCode
public function dirname($uri = NULL) {
if (!isset($uri)) {
$uri = $this->uri;
}
$scheme = StreamWrapperManager::getScheme($uri);
$dirname = dirname($this->streamWrapperManager::getTarget($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}";
}