On this page
function drupal_dirname
drupal_dirname($uri)
Gets the name of the directory from a given path.
PHP's dirname() does not properly pass streams, so this function fills that gap. It is backwards compatible with normal paths and will use PHP's dirname() as a fallback.
Compatibility: normal paths and stream wrappers.
Parameters
$uri: A URI or path.
Return value
A string containing the directory name.
See also
dirname()
Related topics
File
- includes/file.inc, line 2343
- API for handling file uploads and server file management.
Code
function drupal_dirname($uri) {
$scheme = file_uri_scheme($uri);
if ($scheme && file_stream_wrapper_valid_scheme($scheme)) {
return file_stream_wrapper_get_instance_by_scheme($scheme)->dirname($uri);
}
else {
return dirname($uri);
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!file.inc/function/drupal_dirname/7.x