You are here

function file_directory_os_temp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/includes/file.inc \file_directory_os_temp()

Discovers a writable system-appropriate temporary directory.

Return value

mixed A string containing the path to the temporary directory.

Related topics

2 calls to file_directory_os_temp()
file_directory_temp in core/includes/file.inc
Gets and sets the path of the configured temporary directory.
system_requirements in core/modules/system/system.install
Implements hook_requirements().

File

core/includes/file.inc, line 1136
API for handling file uploads and server file management.

Code

function file_directory_os_temp() {
  $directories = array();

  // Has PHP been set with an upload_tmp_dir?
  if (ini_get('upload_tmp_dir')) {
    $directories[] = ini_get('upload_tmp_dir');
  }

  // Operating system specific dirs.
  if (substr(PHP_OS, 0, 3) == 'WIN') {
    $directories[] = 'c:\\windows\\temp';
    $directories[] = 'c:\\winnt\\temp';
  }
  else {
    $directories[] = '/tmp';
  }

  // PHP may be able to find an alternative tmp directory.
  $directories[] = sys_get_temp_dir();
  foreach ($directories as $directory) {
    if (is_dir($directory) && is_writable($directory)) {
      return $directory;
    }
  }
  return FALSE;
}