drupal_realpath

  1. drupal
    1. 7
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.

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.

See also

http://php.net/manual/en/function.realpath.php

Compatibility: normal paths and stream wrappers.

http://drupal.org/node/515192

realpath()

Related topics

▾ 18 functions call drupal_realpath()

archiver_get_archiver in drupal/includes/common.inc
Create the appropriate archiver for the specified file.
DrupalWebTestCase::drupalPost in drupal/modules/simpletest/drupal_web_test_case.php
Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
FileTransfer::checkPath in drupal/includes/filetransfer/filetransfer.inc
Checks that the path is inside the jail and throws an exception if not.
file_copy in drupal/includes/file.inc
Copies a file to a new location and adds a file record to the database.
file_delete in drupal/includes/file.inc
Delete a file and its database record.
file_move in drupal/includes/file.inc
Move a file to a new location and update the file's database entry.
file_unmanaged_copy in drupal/includes/file.inc
Copies a file to a new location without invoking the file API.
file_unmanaged_delete in drupal/includes/file.inc
Delete a file without calling any hooks or making any changes to the database.
file_unmanaged_delete_recursive in drupal/includes/file.inc
Recursively delete all files and directories in the specified filepath.
image_gd_get_info in drupal/modules/system/image.gd.inc
Get details about an image.
image_gd_save in drupal/modules/system/image.gd.inc
GD helper to write an image resource to a destination file.
image_style_flush in drupal/modules/image/image.module
Flush cached media for a style.
system_retrieve_file in drupal/modules/system/system.module
Attempts to get a file using drupal_http_request and to store it locally.
update_manager_file_get in drupal/modules/update/update.manager.inc
Copies a file from $url to the temporary directory for updates.
update_manager_install_form_submit in drupal/modules/update/update.manager.inc
Handle form submission when installing new projects via the update manager.
update_manager_update_ready_form_submit in drupal/modules/update/update.manager.inc
Submit handler for the form to confirm that an update should continue.
_color_render_images in drupal/modules/color/color.module
Render images that match a given palette.
_system_theme_settings_validate_path in drupal/modules/system/system.admin.inc
Helper function for the system_theme_settings form.

Code

drupal/includes/file.inc, line 2166

<?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();
  }
  // Check that the uri has a value. There is a bug in PHP 5.2 on *BSD systems
  // that makes realpath not return FALSE as expected when passing an empty
  // variable.
  // @todo Remove when Drupal drops support for PHP 5.2.
  elseif (!empty($uri)) {
    return realpath($uri);
  }
  return FALSE;
}
?>