function drush_save_data_to_temp_file

8.0.x filesystem.inc drush_save_data_to_temp_file($data, $suffix = NULL)
6.x filesystem.inc drush_save_data_to_temp_file($data, $suffix = NULL)
7.x filesystem.inc drush_save_data_to_temp_file($data, $suffix = NULL)
3.x drush.inc drush_save_data_to_temp_file($data)
4.x drush.inc drush_save_data_to_temp_file($data)
5.x filesystem.inc drush_save_data_to_temp_file($data, $suffix = NULL)
master filesystem.inc drush_save_data_to_temp_file($data, $suffix = NULL)

Save a string to a temporary file. Does not depend on Drupal's API. The temporary file will be automatically deleted when drush exits.

Parameters

string $data:

string $suffix: Append string to filename. use of this parameter if is discouraged. @see drush_tempnam().

Return value

string A path to the file.

Related topics

5 calls to drush_save_data_to_temp_file()
drush_engine_topic_command in includes/engines.inc
Implementation of command hook for docs-output-formats
SqlBase::query in lib/Drush/Sql/SqlBase.php
Execute a SQL query.
Sqlmysql::creds in lib/Drush/Sql/Sqlmysql.php
Build a fragment connection parameters.
Sqlpgsql::password_file in lib/Drush/Sql/Sqlpgsql.php
_drush_config_export in commands/core/config.drush.inc

File

includes/filesystem.inc, line 415
Filesystem utilities.

Code

function drush_save_data_to_temp_file($data, $suffix = NULL) {
  static $fp;

  $file = drush_tempnam('drush_', NULL, $suffix);
  $fp = fopen($file, "w");
  fwrite($fp, $data);
  $meta_data = stream_get_meta_data($fp);
  $file = $meta_data['uri'];
  fclose($fp);

  return $file;
}