function drush_directory_cache

8.0.x environment.inc drush_directory_cache($subdir = '')
6.x environment.inc drush_directory_cache($subdir = '')
7.x environment.inc drush_directory_cache($subdir = '')
4.x environment.inc drush_directory_cache()
5.x environment.inc drush_directory_cache($subdir = '')
master environment.inc drush_directory_cache($subdir = '')

The path to the global cache directory.

Parameters

subdir: Return the specified subdirectory inside the global cache directory instead. The subdirectory is created.

6 calls to drush_directory_cache()
drush_cache_clear_drush in commands/core/cache.drush.inc
Clear caches internal to drush core.
drush_download_file_name in includes/drush.inc
Helper function to determine name of cached file.
FileCache::cacheDirectory in lib/Drush/Cache/FileCache.php
Returns the cache directory for the given bin.
make_download_git in commands/make/make.download.inc
Checks out a git repository to the specified download location.
package_handler_download_project in commands/pm/package_handler/git_drupalorg.inc
Download a project.

... See full list

File

includes/environment.inc, line 677
Functions used by drush to query the environment and setting the current configuration.

Code

function drush_directory_cache($subdir = '') {
  $cache_locations = array();
  if (getenv('CACHE_PREFIX')) {
    $cache_locations[getenv('CACHE_PREFIX')] = 'cache';
  }
  $home = drush_server_home();
  if ($home) {
    $cache_locations[$home] = '.drush/cache';
  }
  $cache_locations[drush_find_tmp()] = 'drush-' . drush_get_username() . '/cache';
  foreach ($cache_locations as $base => $dir) {
    if (!empty($base) && is_writable($base)) {
      $cache_dir = $base . '/' . $dir;
      if (!empty($subdir)) {
        $cache_dir .= '/' . $subdir;
      }
      if (drush_mkdir($cache_dir)) {
        return $cache_dir;
      }
      else {
        // If the base directory is writable, but the cache directory
        // is not, then we will get an error. The error will be displayed,
        // but we will still call drush_clear_error so that we can go
        // on and try the next location to see if we can find a cache
        // directory somewhere.
        drush_clear_error();
      }
    }
  }
  return drush_set_error('DRUSH_NO_WRITABLE_CACHE', dt('Drush must have a writable cache directory; please insure that one of the following locations is writable: @locations', array('@locations' => implode(',', array_keys($cache_locations)))));
}