function drush_tempnam

8.0.x drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '')
6.x drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '')
7.x drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '')
3.x drush_tempnam($pattern, $tmp_dir = NULL)
4.x drush_tempnam($pattern, $tmp_dir = NULL)
5.x drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '')
master drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '')

Creates a temporary file, and registers it so that it will be deleted when drush exits. Whenever possible, drush_save_data_to_temp_file() should be used instead of this function.


string $suffix: Append this suffix to the filename. Use of this parameter is discouraged as it can break the guarantee of tempname(). See Originally added to support Oracle driver.

Related topics

10 calls to drush_tempnam()
drush_docs_errorcodes in commands/core/
docs-errorcodes command. Print a list of all error codes that can be found.
drush_pm_updatecode in commands/pm/
Command callback. Displays update status info and allows to update installed projects.
drush_print_file in includes/
Print the contents of a file.
drush_save_data_to_temp_file in includes/
Save a string to a temporary file. Does not depend on Drupal's API. The temporary file will be automatically deleted when drush exits.
drush_tarball_extract in includes/
Extract a tarball.

... See full list


includes/, line 499
Filesystem utilities.


function drush_tempnam($pattern, $tmp_dir = NULL, $suffix = '') {
  if ($tmp_dir == NULL) {
    $tmp_dir = drush_find_tmp();
  $tmp_file = tempnam($tmp_dir, $pattern);
  $tmp_file_with_suffix = $tmp_file . $suffix;
  return $tmp_file_with_suffix;