• Модуль: webdav
  • Путь к файлу: ~/bitrix/modules/webdav/classes/webdavstorage.php
  • Класс: CWebDavStorageCore
  • Вызов: CWebDavStorageCore::addDirectory
public function addDirectory($name, $parentDirectoryId)
{
	$key = $this->getStorageId();
	if(!$parentDirectoryId)
	{
		//in root
		$parentDirectoryId = $key['IBLOCK_SECTION_ID'];
	}
	/** @var CWebDavIblock $webDav  */
	$webDav = $this
		->init()
		->getWebDav()
	;

	$alreadyExists = false;
	$sectionId = null;
	$name = $webDav->correctName($name);
	$pathArray = $this->getPathArrayForSection($parentDirectoryId);
	$pathArray[] = $name;
	$path = '/' . implode('/', $pathArray);
	$response = $webDav->MKCOL(array('path' => $path));

	if(intval($response) == 403)
	{
		throw new CWebDavAccessDeniedException;
	}
	elseif($exception = $this->getLastException())
	{
		if($exception['code'] == 'FOLDER_IS_EXISTS')
		{
			$alreadyExists = true;
			$sectionId = $webDav->arParams['item_id'];
		}
		else
		{
			return array();
		}
	}
	elseif($response == '201 Created')
	{
		$sectionId = $webDav->arParams['changed_element_id'];
	}

	if(!$sectionId)
	{
		return array();
	}
	if(!$alreadyExists)
	{
		$this->clearCache();
	}

	return $this->getDirectory(null, array('id' => $sectionId), true);
}