• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/tar_gz.php
  • Класс: CArchiver
  • Вызов: CArchiver::Pack
public function Pack($arFileList, $startFile = "")
{
	$this->_arErrors = [];
	$this->startFile = $this->io->GetPhysicalName($startFile);

	$bNewArchive = true;
	if (file_exists($this->io->GetPhysicalName($this->_strArchiveName))
		&& is_file($this->io->GetPhysicalName($this->_strArchiveName)) && ($startFile != ""))
	{
		$bNewArchive = false;
	}

	if ($bNewArchive)
	{
		if (!$this->_openWrite())
		{
			return false;
		}
	}
	else
	{
		if (!$this->_openAppendFast())
		{
			return false;
		}
	}

	$res = false;
	$arFileList = $this->_parseFileParams($arFileList);

	$arConvertedFileList = [];
	foreach ($arFileList as $fullpath)
	{
		$arConvertedFileList[] = $this->io->GetPhysicalName($fullpath);
	}

	$this->tempres = null;

	if (is_array($arFileList) && !empty($arFileList))
	{
		$res = $this->_processFiles($arConvertedFileList, $this->add_path, $this->remove_path, $this->startFile);
	}

	if ($res !== false && $res !== "continue")
	{
		$this->_writeFooter();
	}

	$this->_close();

	if ($bNewArchive && ($res === false))
	{
		$this->_cleanFile();
	}

	//if packing is not completed, remember last file
	if ($res === 'continue')
	{
		$this->startFile = $this->io->GetLogicalName(array_pop($this->lastFile));
	}

	if ($res === false)
	{
		return IBXArchive::StatusError;
	}
	elseif ($res && $this->startFile == "")
	{
		return IBXArchive::StatusSuccess;
	}
	elseif ($res && $this->startFile != "")
	{
		return IBXArchive::StatusContinue;
		//call Pack() with $this->getStartFile() next time to continue
	}
	return null;
}