summaryrefslogtreecommitdiff
path: root/includes/file.inc
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-07-14 09:56:03 -0400
committerwebchick <webchick@24967.no-reply.drupal.org>2011-07-14 09:56:03 -0400
commit5dc4ddd927928a2a6b0209331d3d66d201d3e7b5 (patch)
tree45462ca0452d0d6fa5dda26a3d0343894053cb90 /includes/file.inc
parent6c410f7175b3693fb0c25319cfe281b611cb2345 (diff)
downloadbrdo-5dc4ddd927928a2a6b0209331d3d66d201d3e7b5.tar.gz
brdo-5dc4ddd927928a2a6b0209331d3d66d201d3e7b5.tar.bz2
Issue #1019470 by benjamin.wss, bfroehle: Ensure that file_directory_temp() works on Windows.
Diffstat (limited to 'includes/file.inc')
-rw-r--r--includes/file.inc12
1 files changed, 8 insertions, 4 deletions
diff --git a/includes/file.inc b/includes/file.inc
index ff45b3370..19420ca37 100644
--- a/includes/file.inc
+++ b/includes/file.inc
@@ -2348,11 +2348,9 @@ function file_directory_temp() {
if (substr(PHP_OS, 0, 3) == 'WIN') {
$directories[] = 'c:\\windows\\temp';
$directories[] = 'c:\\winnt\\temp';
- $path_delimiter = '\\';
}
else {
$directories[] = '/tmp';
- $path_delimiter = '/';
}
// PHP may be able to find an alternative tmp directory.
// This function exists in PHP 5 >= 5.2.1, but Drupal
@@ -2369,8 +2367,14 @@ function file_directory_temp() {
}
if (empty($temporary_directory)) {
- // If no directory has been found default to 'files/tmp' or 'files\\tmp'.
- $temporary_directory = variable_get('file_public_path', conf_path() . '/files') . $path_delimiter . 'tmp';
+ // If no directory has been found default to 'files/tmp'.
+ $temporary_directory = variable_get('file_public_path', conf_path() . '/files') . '/tmp';
+
+ // Windows accepts paths with either slash (/) or backslash (\), but will
+ // not accept a path which contains both a slash and a backslash. Since
+ // the 'file_public_path' variable may have either format, we sanitize
+ // everything to use slash which is supported on all platforms.
+ $temporary_directory = str_replace('\\', '/', $temporary_directory);
}
// Save the path of the discovered directory.
variable_set('file_temporary_path', $temporary_directory);