function _make_download_file_move

8.0.x make.download.inc _make_download_file_move($tmp_path, $filename, $download_location, $subtree = NULL)
6.x make.download.inc _make_download_file_move($tmp_path, $filename, $download_location, $subtree = NULL)
7.x make.download.inc _make_download_file_move($tmp_path, $filename, $download_location, $subtree = NULL)
5.x make.download.inc _make_download_file_move($tmp_path, $filename, $download_location, $subtree = NULL)

Move a downloaded and unpacked file or directory into place.

TODO merge with core drush methods.

File

commands/make/make.download.inc, line 162
Download-specific functions for Drush Make.

Code

function _make_download_file_move($tmp_path, $filename, $download_location, $subtree = NULL) {
  $lines = drush_scan_directory($tmp_path, '/./', array('.', '..'), 0, FALSE, 'filename', 0, TRUE);
  $main_directory = basename($download_location);
  if (count($lines) == 1) {
    $directory = array_shift($lines);
    if ($directory->basename != $main_directory) {
      drush_move_dir($directory->filename, $tmp_path . DIRECTORY_SEPARATOR . $main_directory, TRUE);
    }
    drush_copy_dir($tmp_path . DIRECTORY_SEPARATOR . $main_directory . DIRECTORY_SEPARATOR . $subtree, $download_location, TRUE);
    drush_delete_dir($tmp_path, TRUE);
  }
  elseif (count($lines) > 1) {
    drush_delete_dir($download_location, TRUE);
    drush_move_dir($tmp_path . DIRECTORY_SEPARATOR . $subtree, $download_location, TRUE);
  }

  // Remove the tarball.
  if (file_exists($filename)) {
    drush_delete_dir($filename, TRUE);
  }

  if (file_exists($tmp_path)) {
    drush_delete_dir($tmp_path, TRUE);
  }
  return TRUE;
}