core-bundle/src/Resources/contao/library/Contao/Folder.php
public function protect()
	{
		if (!$this->isUnprotected())
		{
			return;
		}

		// Check if the .public file exists
		if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.public'))
		{
			throw new \RuntimeException(sprintf('Cannot protect folder "%s" because one of its parent folders is public', $this->strFolder));
		}

		(new File($this->strFolder . '/.public'))->delete();
	}
public function protect()
	{
		if (!$this->isUnprotected())
		{
			return;
		}

		// Check if the .public file exists
		if (!file_exists($this->strRootDir . '/' . $this->strFolder . '/.public'))
		{
			throw new \RuntimeException(sprintf('Cannot protect folder "%s" because one of its parent folders is public', $this->strFolder));
		}

		(new File($this->strFolder . '/.public'))->delete();
	}
Protect the folder by removing the .public file

@throws \RuntimeException If one of the parent folders is public