You are here

public function Archive_Tar::_addString in Drupal 7

Parameters

string $p_filename:

string $p_string:

bool $p_datetime:

array $p_params:

Return value

bool

1 call to Archive_Tar::_addString()
Archive_Tar::addString in modules/system/system.tar.inc
This method add a single string as a file at the end of the existing archive. If the archive does not yet exists it is created.

File

modules/system/system.tar.inc, line 1366

Class

Archive_Tar

Code

public function _addString($p_filename, $p_string, $p_datetime = false, $p_params = array()) {
  $p_stamp = @$p_params["stamp"] ? $p_params["stamp"] : ($p_datetime ? $p_datetime : time());
  $p_mode = @$p_params["mode"] ? $p_params["mode"] : 0600;
  $p_type = @$p_params["type"] ? $p_params["type"] : "";
  $p_uid = @$p_params["uid"] ? $p_params["uid"] : 0;
  $p_gid = @$p_params["gid"] ? $p_params["gid"] : 0;
  if (!$this->_file) {
    $this
      ->_error('Invalid file descriptor');
    return false;
  }
  if ($p_filename == '') {
    $this
      ->_error('Invalid file name');
    return false;
  }

  // ----- Calculate the stored filename
  $p_filename = $this
    ->_translateWinPath($p_filename, false);

  // ----- If datetime is not specified, set current time
  if ($p_datetime === false) {
    $p_datetime = time();
  }
  if (!$this
    ->_writeHeaderBlock($p_filename, strlen($p_string), $p_stamp, $p_mode, $p_type, $p_uid, $p_gid)) {
    return false;
  }
  $i = 0;
  while (($v_buffer = substr($p_string, $i++ * 512, 512)) != '') {
    $v_binary_data = pack("a512", $v_buffer);
    $this
      ->_writeBlock($v_binary_data);
  }
  return true;
}