• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/tar_gz.php
  • Класс: CArchiver
  • Вызов: CArchiver::_writeHeaderBlock
private function _writeHeaderBlock($strFilename, $iSize, $p_mtime = 0, $p_perms = 0, $p_type = '', $p_uid = 0, $p_gid = 0)
{
	$strFilename = $this->_normalizePath($strFilename);

	if (mb_strlen($strFilename) > 99)
	{
		if (!$this->_writeLongHeader($strFilename))
		{
			return false;
		}
	}

	if ($p_type == "5")
	{
		$v_size = sprintf("%11s ", DecOct(0));
	}
	else
	{
		$v_size = sprintf("%11s ", DecOct($iSize));
	}

	$v_uid = sprintf("%6s ", DecOct($p_uid));
	$v_gid = sprintf("%6s ", DecOct($p_gid));
	$v_perms = sprintf("%6s ", DecOct($p_perms));
	$v_mtime = sprintf("%11s", DecOct($p_mtime));
	$v_linkname = '';
	$v_magic = '';
	$v_version = '';
	$v_uname = '';
	$v_gname = '';
	$v_devmajor = '';
	$v_devminor = '';
	$v_prefix = '';

	$v_binary_data_first = pack("a100a8a8a8a12A12", $strFilename, $v_perms, $v_uid, $v_gid, $v_size, $v_mtime);
	$v_binary_data_last = pack("a1a100a6a2a32a32a8a8a155a12", $p_type, $v_linkname, $v_magic, $v_version, $v_uname, $v_gname, $v_devmajor, $v_devminor, $v_prefix, '');

	$v_checksum = 0;
	for ($i = 0; $i < 148; $i++)
	{
		$v_checksum += ord(substr($v_binary_data_first, $i, 1));
	}
	for ($i = 148; $i < 156; $i++)
	{
		$v_checksum += ord(' ');
	}
	for ($i = 156, $j = 0; $i < 512; $i++, $j++)
	{
		$v_checksum += ord(substr($v_binary_data_last, $j, 1));
	}

	$this->_writeBlock($v_binary_data_first, 148);

	$v_checksum = sprintf("%6s ", DecOct($v_checksum));
	$v_binary_data = pack("a8", $v_checksum);
	$this->_writeBlock($v_binary_data, 8);

	$this->_writeBlock($v_binary_data_last, 356);

	return true;
}