core-bundle/src/Resources/contao/library/Contao/Files.php
public function rrdir($strFolder, $blnPreserveRoot=false)
	{
		$this->validate($strFolder);
		$arrFiles = scan($this->strRootDir . '/' . $strFolder, true);

		foreach ($arrFiles as $strFile)
		{
			if (is_link($this->strRootDir . '/' . $strFolder . '/' . $strFile))
			{
				$this->delete($strFolder . '/' . $strFile);
			}
			elseif (is_dir($this->strRootDir . '/' . $strFolder . '/' . $strFile))
			{
				$this->rrdir($strFolder . '/' . $strFile);
			}
			else
			{
				$this->delete($strFolder . '/' . $strFile);
			}
		}

		if (!$blnPreserveRoot)
		{
			$this->rmdir($strFolder);
		}
	}
public function rrdir($strFolder, $blnPreserveRoot=false)
	{
		$this->validate($strFolder);
		$arrFiles = scan($this->strRootDir . '/' . $strFolder, true);

		foreach ($arrFiles as $strFile)
		{
			if (is_link($this->strRootDir . '/' . $strFolder . '/' . $strFile))
			{
				$this->delete($strFolder . '/' . $strFile);
			}
			elseif (is_dir($this->strRootDir . '/' . $strFolder . '/' . $strFile))
			{
				$this->rrdir($strFolder . '/' . $strFile);
			}
			else
			{
				$this->delete($strFolder . '/' . $strFile);
			}
		}

		if (!$blnPreserveRoot)
		{
			$this->rmdir($strFolder);
		}
	}
Recursively remove a directory

@param string  $strFolder       The directory name
@param boolean $blnPreserveRoot If true, the root folder will not be removed