You are here

public function ArchiveTar::addString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Archiver/ArchiveTar.php \Drupal\Core\Archiver\ArchiveTar::addString()

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.

Parameters

string $p_filename A string which contains the full: filename path that will be associated with the string.

string $p_string The content of the file added in: the archive.

bool|int $p_datetime A custom date/time (unix timestamp): for the file (optional).

array $p_params An array of optional params:: stamp => the datetime (replaces datetime above if it exists) mode => the permissions on the file (600 by default) type => is this a link? See the tar specification for details. (default = regular file) uid => the user ID of the file (default = 0 = root) gid => the group ID of the file (default = 0 = root)

Return value

true on success, false on error.

File

core/lib/Drupal/Core/Archiver/ArchiveTar.php, line 544

Class

ArchiveTar

Namespace

Drupal\Core\Archiver

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"] : "";
  $p_gid = @$p_params["gid"] ? $p_params["gid"] : "";
  $v_result = true;
  if (!$this
    ->_isArchive()) {
    if (!$this
      ->_openWrite()) {
      return false;
    }
    $this
      ->_close();
  }
  if (!$this
    ->_openAppend()) {
    return false;
  }

  // Need to check the get back to the temporary file ? ....
  $v_result = $this
    ->_addString($p_filename, $p_string, $p_datetime, $p_params);
  $this
    ->_writeFooter();
  $this
    ->_close();
  return $v_result;
}