drupal_realpath
- Versions
- 7
drupal_realpath($uri)
Returns the absolute path of a file or directory
PHP's realpath() does not properly support streams, so this function fills that gap. If a stream wrapped URI is provided, it will be passed to the registered wrapper for handling. If the URI does not contain a scheme or the wrapper implementation does not implement realpath, then FALSE will be returned.
See also
http://php.net/manual/en/function.realpath.php
Compatibility: normal paths and stream wrappers.
See also
See also
realpath()
Parameters
$uri A string containing the URI to verify. If this value is omitted, Drupal's public files directory will be used [public://].
Return value
The absolute pathname, or FALSE on failure.
Related topics
Code
includes/file.inc, line 1794
<?php
function drupal_realpath($uri) {
// If this URI is a stream, pass it off to the appropriate stream wrapper.
// Otherwise, attempt PHP's realpath. This allows use of drupal_realpath even
// for unmanaged files outside of the stream wrapper interface.
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
return $wrapper->realpath();
}
else {
return realpath($uri);
}
}
?>Login or register to post comments 