function session_cache_file_directory in Session Cache API 7
Same name and namespace in other branches
- 8 session_cache_file/session_cache_file.module \session_cache_file_directory()
Returns the directory path to where session cache files are stored.
Parameters
string $bin: The bin for which the path is to be returned, NULL for the base path.
Return value
boolean|string The existing or newly created path, or FALSE if there was an error.
5 calls to session_cache_file_directory()
- session_cache_file_cron in session_cache_file/
session_cache_file.module - Implements hook_cron().
- session_cache_file_requirements in session_cache_file/
session_cache_file.install - Implements hook_requirements().
- session_cache_file_session_cache_get in session_cache_file/
session_cache_file.module - Implements hook_session_cache_get().
- session_cache_file_session_cache_set in session_cache_file/
session_cache_file.module - Implements hook_session_cache_set().
- session_cache_file_uninstall in session_cache_file/
session_cache_file.install - Implements hook_uninstall().
File
- session_cache_file/
session_cache_file.module, line 33 - session_cache_file.module
Code
function session_cache_file_directory($bin = NULL) {
$path = variable_get('file_private_path');
// Typically $path == 'sites/default/files/private'.
if (empty($path)) {
drupal_set_message(t('Session Cache File: the <strong>Private file system path</strong> is not set. Please configure it <a href="@url">here</a>.', array(
'@url' => url('admin/config/media/file-system'),
)), 'warning', FALSE);
return FALSE;
}
// Use the absolute path as is, if it starts with a slash.
$path = preg_match('/^\\//', $path) ? $path : DRUPAL_ROOT . "/{$path}";
$path .= '/session_cache';
// @todo Use file_prepare_directory(&$path, FILE_CREATE_DIRECTORY)
if (!file_exists($path) && !@mkdir($path)) {
drupal_set_message(t('Session cache directory %path could not be created.', array(
'%path' => $path,
)), 'error', FALSE);
return FALSE;
}
if (empty($bin)) {
return $path;
}
if (!file_exists("{$path}/{$bin}") && !@mkdir("{$path}/{$bin}")) {
drupal_set_message(t('Session cache subdirectory %bin could not be created inside %path', array(
'%bin' => $bin,
'%path' => $path,
)), 'error', FALSE);
return FALSE;
}
return "{$path}/{$bin}";
}