function pm_dl_destination_lookup

3.x pm.drush.inc pm_dl_destination_lookup($type, $drupal_root, $sitepath, $create = FALSE)
4.x pm.drush.inc pm_dl_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_dl_destination_lookup()
pm_dl_destination in commands/pm/pm.drush.inc
Return the best destination for a particular download type we can find, given the drupal and site contexts.

File

commands/pm/pm.drush.inc, line 995
The drush Package Manager

Code

function pm_dl_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 'translation':
      $destination = $drupal_root . '/';
      break;
    case 'profile':
      $destination = $drupal_root . '/profiles/';
      break;
  }
  if ($create) {
    drush_log(dt('Attempting to create destination directory at !dir', array('!dir' => $destination)));
    @drush_op('mkdir', $destination, 0777, 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;
}