function drush_include

8.0.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
6.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
7.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
3.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
4.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
5.x drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')
master drush.inc drush_include($path, $name, $version = NULL, $extension = 'inc')

Include a file, selecting a version specific file if available.

For example, if you pass the path "/var/drush" and the name "update" when bootstrapped on a Drupal 6 site it will first check for the presence of "/var/drush/update_6.inc" in include it if exists. If this file does NOT exist it will proceed and check for "/var/drush/update.inc". If neither file exists, it will return FALSE.

Parameters

$path: The path you want to search.

$name: The file base name you want to include (not including a version suffix or extension).

$version: The version suffix you want to include (could be specific to the software or platform your are connecting to) - defaults to the current Drupal core major version.

$extension: The extension - defaults to ".inc".

Return value

TRUE if the file was found and included.

1 call to drush_include()
drush_include_engine in includes/engines.inc
Include the engine code for a specific named engine of a certain type.

File

includes/drush.inc, line 72
The drush API implementation and helpers.

Code

function drush_include($path, $name, $version = NULL, $extension = 'inc') {
  $name = str_replace('-', '_', $name);
  $version = ($version) ? $version : drush_drupal_major_version();

  $file = sprintf("%s/%s_%s.%s", $path, $name, $version, $extension);
  if (file_exists($file)) {
    include_once ($file);
    return TRUE;
  }
  $file = sprintf("%s/%s.%s", $path, $name, $extension);
  if (file_exists($file)) {
    include_once ($file);
    return TRUE;
  }

  return drush_set_error('DRUSH_INCLUDE_NO_PATH', dt('Unable to include file !name!version!extension or !name!extension from !path.', array('!name' => $name, '!version' => $version, '!extension' => $extension)));
}