function drush_is_absolute_path

8.0.x filesystem.inc drush_is_absolute_path($path, $os = NULL)
6.x filesystem.inc drush_is_absolute_path($path, $os = NULL)
7.x filesystem.inc drush_is_absolute_path($path, $os = NULL)
5.x filesystem.inc drush_is_absolute_path($path, $os = NULL)
master filesystem.inc drush_is_absolute_path($path, $os = NULL)

Determines whether the provided path is absolute or not on the specified O.S. -- starts with "/" on *nix, or starts with "[A-Z]:\" or "[A-Z]:/" on Windows.

Related topics

3 calls to drush_is_absolute_path()
drush_correct_absolute_path_for_exec in includes/filesystem.inc
If we are going to pass a path to exec or proc_open, then we need to fix it up under CYGWIN or MINGW. In both of these environments, PHP works with absolute paths such as "C:\path". CYGWIN expects these to be converted to…
drush_sitealias_evaluate_path in includes/sitealias.inc
Evaluate a path from its shorthand form to a literal path usable by rsync.
_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/filesystem.inc, line 20

Code

function drush_is_absolute_path($path, $os = NULL) {
  // Relative paths will never start with a '/', even on Windows,
  // so it is safe to just call all paths that start with a '/'
  // absolute.  This simplifies things for Windows with CYGWIN / MINGW / CWRSYNC,
  // where absolute paths sometimes start c:\path and sometimes
  // start /cygdrive/c/path.
  if ($path[0] == '/') {
    return TRUE;
  }
  if (drush_is_windows($os)) {
    return preg_match('@^[a-zA-Z]:[\\\/]@', $path);
  }
  return FALSE;
}