Gets and sets the path of the configured temporary directory.
mixed|null A string containing the path to the temporary directory.
function file_directory_temp() {
$config = config('system.file');
$temporary_directory = $config
->get('path.temporary');
if (empty($temporary_directory)) {
$temporary_directory = file_directory_os_temp();
if (empty($temporary_directory)) {
// 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.
$config
->set('path.temporary', $temporary_directory)
->save();
}
return $temporary_directory;
}