function _drush_recursive_copy

8.0.x filesystem.inc _drush_recursive_copy($src, $dest)
6.x filesystem.inc _drush_recursive_copy($src, $dest)
7.x filesystem.inc _drush_recursive_copy($src, $dest)
4.x drush.inc _drush_recursive_copy($src, $dest)
5.x filesystem.inc _drush_recursive_copy($src, $dest)
master filesystem.inc _drush_recursive_copy($src, $dest)

Internal function called by drush_copy_dir; do not use directly.

Related topics

2 string references to '_drush_recursive_copy'
drush_copy_dir in includes/filesystem.inc
Copy $src to $dest.
drush_pm_download in commands/pm/download.pm.inc
Command callback. Download Drupal core or any project.

File

includes/filesystem.inc, line 248
Filesystem utilities.

Code

function _drush_recursive_copy($src, $dest) {
  // all subdirectories and contents:
  if (is_dir($src)) {
    if (!drush_mkdir($dest, TRUE)) {
      return FALSE;
    }
    $dir_handle = opendir($src);
    while ($file = readdir($dir_handle)) {
      if ($file != "." && $file != "..") {
        if (_drush_recursive_copy("$src/$file", "$dest/$file") !== TRUE) {
          return FALSE;
        }
      }
    }
    closedir($dir_handle);
  }
  elseif (is_link($src)) {
    symlink(readlink($src), $dest);
  }
  elseif (!copy($src, $dest)) {
    return FALSE;
  }

  // Preserve file modification time.
  // https://github.com/drush-ops/drush/pull/1146
  touch($dest, filemtime($src));

  // Preserve execute permission.
  if (!is_link($src) && !drush_is_windows()) {
    // Get execute bits of $src.
    $execperms = fileperms($src) & 0111;
    // Apply execute permissions if any.
    if ($execperms > 0) {
      $perms = fileperms($dest) | $execperms;
      chmod($dest, $perms);
    }
  }

  return TRUE;
}