Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.842 diff -u -p -r1.842 common.inc --- includes/common.inc 5 Jan 2009 22:23:58 -0000 1.842 +++ includes/common.inc 7 Jan 2009 21:04:08 -0000 @@ -1595,6 +1595,7 @@ function format_date($timestamp, $type = * The Drupal path being linked to, such as "admin/content/node", or an * existing URL like "http://drupal.org/". The special path * '' may also be given and will generate the site's base URL. + * The path can also be a file such as "sites/default/files/drupalicon.png". * @param $options * An associative array of additional options, with the following keys: * - 'query' @@ -1711,7 +1712,17 @@ function url($path = NULL, array $option $prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix']; $path = drupal_urlencode($prefix . $path); - if ($clean_url) { + $private_files = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) === FILE_DOWNLOADS_PRIVATE; + if (! $clean_url || $private_files) { + if($is_file = strpos($path, file_directory_path() . '/') === 0) { + if ($private_files) { + $path = trim(substr($path, strlen(file_directory_path())), '\\/'); + $path = 'system/files/' . $path; + } + } + } + + if ($clean_url || ($is_file && ! $private_files)) { // With Clean URLs. if ($options['query']) { return $base . $path . '?' . $options['query'] . $options['fragment']; Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.151 diff -u -p -r1.151 file.inc --- includes/file.inc 6 Jan 2009 12:00:40 -0000 1.151 +++ includes/file.inc 7 Jan 2009 21:04:08 -0000 @@ -78,22 +78,14 @@ define('FILE_STATUS_PERMANENT', 1); /** * Create the download path to a file. + * + * @deprecated Use url() instead. * * @param $path A string containing the path of the file to generate URL for. * @return A string containing a URL that can be used to download the file. */ function file_create_url($path) { - // Strip file_directory_path from $path. We only include relative paths in - // URLs. - if (strpos($path, file_directory_path() . '/') === 0) { - $path = trim(substr($path, strlen(file_directory_path())), '\\/'); - } - switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) { - case FILE_DOWNLOADS_PUBLIC: - return $GLOBALS['base_url'] . '/' . file_directory_path() . '/' . str_replace('\\', '/', $path); - case FILE_DOWNLOADS_PRIVATE: - return url('system/files/' . $path, array('absolute' => TRUE)); - } + return url($path, array('absolute' => TRUE)); } /**