/**
* Create a symbolic link in this folder
*
* @param Folder $target
* @param string $linkName optional link name. If omitted the name will be the same as the target folder name
* @return File
* @throws Exception
*/
public function createLink(Folder $target, $linkName = null)
{
if (!isset($linkName)) {
$linkName = $target->name();
}
$link = $this->createChild($linkName, true);
if ($link->exists()) {
throw new \Exception("Path " . $link->path() . " already exists");
}
if (symlink($target->path(), $link->path())) {
return $link;
} else {
throw new \Exception("Failed to create link " . $link->path() . " to " . $target->path());
}
}