function drush_valid_drupal_root

6.x environment.inc drush_valid_drupal_root($path)
3.x environment.inc drush_valid_drupal_root($path)
4.x environment.inc drush_valid_drupal_root($path)
5.x environment.inc drush_valid_drupal_root($path)

Checks whether given path qualifies as a Drupal root.

Parameters

string: Path to check.

Return value

string The relative path to common.inc (varies by Drupal version), or FALSE if not a Drupal root.

4 calls to drush_valid_drupal_root()
drush_locate_root in includes/environment.inc
Exhaustive depth-first search to try and locate the Drupal root directory. This makes it possible to run drush from a subdirectory of the drupal root.
_drush_bootstrap_drupal_root_validate in includes/bootstrap.inc
Validate the DRUSH_BOOTSTRAP_DRUPAL_ROOT phase.
_drush_find_local_sites_at_root in includes/sitealias.inc
Return a list of all of the local sites at the specified drupal root.
_drush_sitealias_get_record in includes/sitealias.inc
This is a continuation of drush_sitealias_get_record, above. It is not intended to be called directly.

File

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

Code

function drush_valid_drupal_root($path) {
  if (!empty($path) && is_dir($path)) {
    $candidates = array('includes/common.inc', 'core/includes/common.inc');
    foreach ($candidates as $candidate) {
      if (file_exists($path . '/' . $candidate)) {
        return $candidate;
      }
    }
  }
  return FALSE;
}