function make_tmp

8.0.x make.utilities.inc make_tmp($set = TRUE, $directory = NULL)
6.x make.utilities.inc make_tmp($set = TRUE, $directory = NULL)
7.x make.utilities.inc make_tmp($set = TRUE, $directory = NULL)
5.x make.utilities.inc make_tmp($set = TRUE, $directory = NULL)
master make.utilities.inc make_tmp($set = TRUE, $directory = NULL)

Find, and possibly create, a temporary directory.

@todo Merge with drush_tempdir().

Parameters

boolean $set: Must be TRUE to create a directory.

string $directory: Pass in a directory to use. This is required if using any concurrent operations.

12 calls to make_tmp()
DrushMakeProject::generatePath in commands/make/make.project.inc
Generate the proper path for this project type.
drush_make_process in commands/make/make.drush.inc
Drush callback: hidden file to process an individual project.
make_clean_tmp in commands/make/make.utilities.inc
Removes the temporary build directory. On failed builds, this is handled by drush_register_file_for_deletion().
make_download_bzr in commands/make/make.download.inc
Checks out a Bazaar repository to the specified download location.
make_download_git in commands/make/make.download.inc
Checks out a git repository to the specified download location.

... See full list

File

commands/make/make.utilities.inc, line 394
General utility functions for Drush Make.

Code

function make_tmp($set = TRUE, $directory = NULL) {
  static $tmp_dir;

  if (isset($directory) && !isset($tmp_dir)) {
    $tmp_dir = $directory;
  }

  if (!isset($tmp_dir) && $set) {
    $tmp_dir = drush_find_tmp();
    if (strrpos($tmp_dir, '/') == strlen($tmp_dir) - 1) {
      $tmp_dir .= 'make_tmp_' . time() . '_' . uniqid();
    }
    else {
      $tmp_dir .= '/make_tmp_' . time() . '_' . uniqid();
    }
    if (!drush_get_option('no-clean', FALSE)) {
      drush_register_file_for_deletion($tmp_dir);
    }
    if (file_exists($tmp_dir)) {
      return make_tmp(TRUE);
    }
    // Create the directory.
    drush_mkdir($tmp_dir);
  }
  return $tmp_dir;
}