function drush_file_append_data

8.0.x filesystem.inc drush_file_append_data($file, $data)
6.x filesystem.inc drush_file_append_data($file, $data)
7.x filesystem.inc drush_file_append_data($file, $data)
5.x filesystem.inc drush_file_append_data($file, $data)
master filesystem.inc drush_file_append_data($file, $data)

Simple helper function to append data to a given file.

Parameters

string $file: The full path to the file to append the data to.

string $data: The data to append.

Return value

boolean TRUE on success, FALSE in case of failure to open or write to the file.

Related topics

2 calls to drush_file_append_data()
drush_core_pre_site_install in commands/core/site_install.drush.inc
Perform setup tasks for installation.
drush_pm_inject_info_file_metadata in commands/pm/pm.drush.inc
Inject metadata into all .info files for a given project.

File

includes/filesystem.inc, line 719
Filesystem utilities.

Code

function drush_file_append_data($file, $data) {
  if (!$fd = fopen($file, 'a+')) {
    drush_set_error(dt("ERROR: fopen(@file, 'ab') failed", array('@file' => $file)));
    return FALSE;
  }
  if (!fwrite($fd, $data)) {
    drush_set_error(dt("ERROR: fwrite(@file) failed", array('@file' => $file)) . '<pre>' . $data);
    return FALSE;
  }
  return TRUE;
}