function ArchiveTar::_addString

1 call to ArchiveTar::_addString()
ArchiveTar::addString in drupal/core/lib/Drupal/Component/Archiver/ArchiveTar.php
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

drupal/core/lib/Drupal/Component/Archiver/ArchiveTar.php, line 1030

Class

ArchiveTar
Creates a (compressed) Tar archive

Namespace

Drupal\Component\Archiver

Code

function _addString($p_filename, $p_string) {
  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 (!$this
    ->_writeHeaderBlock($p_filename, strlen($p_string), time(), 384, "", 0, 0)) {
    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;
}