function drush_file_append_data

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

Simple helper function to append data to a given file.


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

1 call to drush_file_append_data()
drush_pm_inject_info_file_metadata in commands/pm/
Inject metadata into all .info files for a given project.


includes/, line 704
Filesystem utilities.


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;