• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/tar_gz.php
  • Класс: CArchiver
  • Вызов: CArchiver::_addFileList
private function _addFileList($arFileList, $strAddPath, $strRemovePath)
{
	$v_result = true;
	$strAddPath = str_replace("\", "/", $strAddPath);
	$strRemovePath = str_replace("\", "/", $strRemovePath);

	if (!$this->_dFile)
	{
		$this->_arErrors[] = ["ERR_DFILE", GetMessage("MAIN_ARCHIVE_ERR_DFILE")];
		return false;
	}

	if (!is_array($arFileList) || empty($arFileList))
	{
		return true;
	}

	$fileListCount = count($arFileList);
	for ($j = 0; ($j < $fileListCount) && ($v_result); $j++)
	{
		$strFilename = $arFileList[$j];

		if ($strFilename == $this->_strArchiveName)
		{
			continue;
		}

		if ($strFilename == '')
		{
			continue;
		}

		if (!file_exists($this->io->GetPhysicalName($strFilename)))
		{
			$this->_arErrors[] = ["NO_FILE", "File '" . $strFilename . "' does not exist"];
			continue;
		}

		if (!$this->_addFile($strFilename, $strAddPath, $strRemovePath))
		{
			return false;
		}

		if (@is_dir($this->io->GetPhysicalName($strFilename)))
		{
			if (!($handle = opendir($this->io->GetPhysicalName($strFilename))))
			{
				$this->_arErrors[] = ["NO_READ", str_replace("#DIR_NAME#", $strFilename, GetMessage("MAIN_ARCHIVE_ERR_DFILE"))];
				continue;
			}

			while (false !== ($dir = readdir($handle)))
			{
				if ($dir != "." && $dir != "..")
				{
					$arFileList_tmp = [];
					if ($strFilename != ".")
					{
						$arFileList_tmp[] = $strFilename . '/' . $dir;
					}
					else
					{
						$arFileList_tmp[] = $dir;
					}

					$v_result = $this->_addFileList($arFileList_tmp, $strAddPath, $strRemovePath);
				}
			}

			unset($arFileList_tmp);
			unset($dir);
			unset($handle);
		}
	}

	return $v_result;
}