• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/classes/general/zip.php
  • Класс: CZip
  • Вызов: CZip::_reducePath
private function _reducePath($dir)
{
	$res = "";

	if ($dir != "")
	{
		//get directory names
		$arTmpList = explode("/", $dir);

		//check from last to first
		for ($i = sizeof($arTmpList) - 1; $i >= 0; $i--)
		{
			//is current path
			if ($arTmpList[$i] == ".")
			{
				//just ignore. the first $i should be = 0, but no check is done
			}
			else
			{
				if ($arTmpList[$i] == "..")
				{
					//ignore this and ignore the $i-1
					$i--;
				}
				else
				{
					if (($arTmpList[$i] == "") && ($i != (sizeof($arTmpList) - 1)) && ($i != 0))
					{
						//ignore only the double '//' in path, but not the first and last '/'
					}
					else
					{
						$res = $arTmpList[$i] . ($i != (sizeof($arTmpList) - 1) ? "/" . $res : "");
					}
				}
			}
		}
	}
	return $res;
}