function make_get_data

8.0.x make_get_data($data_source)
6.x make_get_data($data_source)
7.x make_get_data($data_source)
5.x make_get_data($data_source)
master make_get_data($data_source)

Get data based on the source.

This is a helper function to abstract the retrieval of data, so that it can come from files, STDIN, etc. Currently supports filepath and STDIN.


string $data_source: The path to a file, or '-' for STDIN.

Return value

string The raw data as a string.

1 call to make_get_data()
_make_parse_info_file in commands/make/
Parse makefile recursively.


commands/make/, line 509
General utility functions for Drush Make.


function make_get_data($data_source) {
  if ($data_source == '-') {
    // See before changing this.
    $stdin = fopen('php://stdin', 'r');
    $data = '';
    $has_input = FALSE;

    while ($line = fgets($stdin)) {
      $has_input = TRUE;
      $data .= $line;

    if ($has_input) {
      return $data;
    return FALSE;
  // Local file.
  elseif (!strpos($data_source, '://')) {
    $data = file_get_contents($data_source);
  // Remote file.
  else {
    $file = _make_download_file($data_source);
    $data = file_get_contents($file);
    drush_op('unlink', $file);
  return $data;