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

http://drupal.org/node/515192

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

▾ 9 functions call drupal_realpath()

archiver_get_archiver in includes/common.inc
Create the appropriate archiver for the specified file.
file_unmanaged_copy in includes/file.inc
Copy a file to a new location without calling any hooks or making any changes to the database.
file_unmanaged_delete in includes/file.inc
Delete a file without calling any hooks or making any changes to the database.
file_unmanaged_delete_recursive in includes/file.inc
Recursively delete all files and directories in the specified filepath.
image_style_flush in modules/image/image.module
Flush cached media for a style.
update_manager_confirm_update_form_submit in modules/update/update.manager.inc
Submit handler for the form to confirm that an update should continue.
update_manager_file_get in modules/update/update.manager.inc
Copies a file from $url to the temporary directory for updates.
update_manager_install_form_submit in modules/update/update.manager.inc
Handle form submission when installing new projects via the update manager.
_color_render_images in modules/color/color.module
Render images that match a given palette.

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
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.