function Archive_Tar::_addString

7.x system.tar.inc Archive_Tar::_addString($p_filename, $p_string)
1 call to Archive_Tar::_addString()
Archive_Tar::addString in drupal-7.x/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

drupal-7.x/modules/system/system.tar.inc, line 1026

Class

Archive_Tar
Creates a (compressed) Tar archive *

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;
}