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

	//explode dir and path by directory separator
	$arTmpDirList = explode("/", $dir);
	$arTmpPathList = explode("/", $path);

	$arTmpDirListSize = sizeof($arTmpDirList);
	$arTmpPathListSize = sizeof($arTmpPathList);

	//check dir paths
	$i = 0;
	$j = 0;

	while (($i < $arTmpDirListSize) && ($j < $arTmpPathListSize) && ($res))
	{
		//check if is empty
		if ($arTmpDirList[$i] == '')
		{
			$i++;
			continue;
		}

		if ($arTmpPathList[$j] == '')
		{
			$j++;
			continue;
		}

		//compare items
		if ($arTmpDirList[$i] != $arTmpPathList[$j])
		{
			$res = 0;
		}

		$i++;
		$j++;
	}

	//check if the same
	if ($res)
	{
		//skip empty items
		while (($j < $arTmpPathListSize) && ($arTmpPathList[$j] == ''))
		{
			$j++;
		}

		while (($i < $arTmpDirListSize) && ($arTmpDirList[$i] == ''))
		{
			$i++;
		}

		if (($i >= $arTmpDirListSize) && ($j >= $arTmpPathListSize))
		{
			//exactly the same
			$res = 2;
		}
		else
		{
			if ($i < $arTmpDirListSize)
			{
				//path is shorter than the dir
				$res = 0;
			}
		}
	}

	return $res;
}