• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/tar_gz.php
  • Класс: CArchiver
  • Вызов: CArchiver::_normalizePath
private function _normalizePath($strPath)
{
	$strResult = "";
	if ($strPath <> '')
	{
		$strPath = str_replace("\", "/", $strPath);

		while (strpos($strPath, ".../") !== false)
		{
			$strPath = str_replace(".../", "../", $strPath);
		}

		$arPath = explode('/', $strPath);
		$nPath = count($arPath);
		for ($i = $nPath - 1; $i >= 0; $i--)
		{
			if ($arPath[$i] == ".")
			{
				;
			}
			elseif ($arPath[$i] == "..")
			{
				$i--;
			}
			elseif (($arPath[$i] == '') && ($i != ($nPath - 1)) && ($i != 0))
			{
				;
			}
			else
			{
				$strResult = $arPath[$i] . ($i != ($nPath - 1) ? '/' . $strResult : '');
			}
		}
	}
	return $strResult;
}