function _pm_download_destination_lookup

8.0.x download.pm.inc _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)
6.x download.pm.inc _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)
7.x download.pm.inc _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)
5.x download.pm.inc _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)
master download.pm.inc _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)

Determine a candidate destination directory for a particular site path and return it if it exists, optionally attempting to create the directory.

1 call to _pm_download_destination_lookup()
_pm_download_destination in commands/pm/download.pm.inc
Returns the best destination for a particular download type we can find.

File

commands/pm/download.pm.inc, line 267

Code

function _pm_download_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE) {
  switch ($type) {
    case 'module':
      // Prefer sites/all/modules/contrib if it exists.
      $destination = $sitepath . '/modules';
      $contrib = $destination . '/contrib';
      if (is_dir($contrib)) {
        $destination = $contrib;
      }
      break;
    case 'theme':
      $destination = $sitepath . '/themes';
      break;
    case 'theme engine':
      $destination = $sitepath . '/themes/engines';
      break;
    case 'profile':
      $destination = $drupal_root . '/profiles';
      break;
  }
  if ($create) {
    drush_log(dt('Attempting to create destination directory at !dir', array('!dir' => $destination)));
    drush_mkdir($destination, TRUE);
  }
  if (is_dir($destination)) {
    drush_log(dt('Using destination directory !dir', array('!dir' => $destination)));
    return $destination;
  }
  drush_log(dt('Could not find destination directory at !dir', array('!dir' => $destination)));
  return FALSE;
}