• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/tar_gz.php
  • Класс: CArchiver
  • Вызов: CArchiver::_openAppend
private function _openAppend()
{
	if (filesize($this->io->GetPhysicalName($this->_strArchiveName)) == 0)
	{
		return $this->_openWrite();
	}

	$this->_checkDirPath($this->_strArchiveName);

	if ($this->_bCompress)
	{
		$this->_close();

		if (!@rename($this->io->GetPhysicalName($this->_strArchiveName), $this->io->GetPhysicalName($this->_strArchiveName . ".tmp")))
		{
			$this->_arErrors[] = ["ERR_RENAME", str_replace(["#FILE_NAME#", "#FILE_NAME2#"], [removeDocRoot($this->_strArchiveName), removeDocRoot($this->_strArchiveName . ".tmp")], GetMessage("MAIN_ARCHIVE_ERR_RENAME"))];
			return false;
		}

		$dTarArch_tmp = @gzopen($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), "rb");
		if (!$dTarArch_tmp)
		{
			$this->_arErrors[] = ["ERR_OPEN", str_replace("#FILE_NAME#", removeDocRoot($this->_strArchiveName . ".tmp"), GetMessage("MAIN_ARCHIVE_ERR_OPEN"))];
			@rename($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), $this->io->GetPhysicalName($this->_strArchiveName));
			return false;
		}

		if (!$this->_openWrite())
		{
			@rename($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"), $this->io->GetPhysicalName($this->_strArchiveName));
			return false;
		}

		$v_buffer = @gzread($dTarArch_tmp, 512);

		if (!@gzeof($dTarArch_tmp))
		{
			do
			{
				$v_binary_data = pack("a512", $v_buffer);
				$this->_writeBlock($v_binary_data);
				$v_buffer = @gzread($dTarArch_tmp, 512);
			}
			while (!@gzeof($dTarArch_tmp));
		}

		@gzclose($dTarArch_tmp);

		@unlink($this->io->GetPhysicalName($this->_strArchiveName . ".tmp"));
	}
	else
	{
		if (!$this->_openReadWrite())
		{
			return false;
		}

		clearstatcache();
		$iSize = filesize($this->io->GetPhysicalName($this->_strArchiveName));
		fseek($this->_dFile, $iSize - 512);
	}

	return true;
}