Create the directory mirror.

@param string $symlinkTarget The Target
@param string $symlinkName The Name

@throws \Exception
326621
public static function createMirror($symlinkTarget, $symlinkName)
    {
        $filesystem = new Filesystem();
        $filesystem->mkdir($symlinkName);
        $filesystem->mirror(
            realpath($symlinkName . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $symlinkTarget),
            $symlinkName,
            null,
            array('copy_on_windows' => true, 'delete' => true, 'override' => true)
        );
    }
1058347
public function exposeDirectory($source, $target)
    {
        $lastException = null;
        foreach ($this->failovers as $failover) {
            try {
                $failover->exposeDirectory($source, $target);
                return; // Return on first success
            } catch (RuntimeException $lastException) {
            }
        }
        if ($lastException) {
            throw $lastException;
        }
    }
708056
function symlink($target, $link)
    {
        if ($this->exists($link)) {
            $this->unlink($link);
        }

        symlink($target, $link);
    }
225792
protected function processSymlink(string $target, $linkData)
    {
        $link = $this->getLink($linkData);

        if (!$link) {
            throw new InvalidArgumentException('No link passed in config');
        }

        if (!$target) {
            throw new InvalidArgumentException('No target passed in config');
        }

        if ($this->fileSystem->isAbsolutePath($target)) {
            throw new InvalidArgumentException(
                sprintf('Invalid symlink target path %s. It must be relative', $target)
            );
        }

        if ($this->fileSystem->isAbsolutePath($link)) {
            throw new InvalidArgumentException(
                sprintf('Invalid symlink link path %s. It must be relative', $link)
            );
        }

        $currentDirectory = realpath(getcwd());
        $targetPath = realpath($currentDirectory . DIRECTORY_SEPARATOR . $target);
        $linkPath = $currentDirectory . DIRECTORY_SEPARATOR . $link;

        if (!is_dir($targetPath) && !is_file($targetPath)) {
            if ($this->getConfig(static::SKIP_MISSED_TARGET, $link)) {
                return null;
            }
            throw new InvalidArgumentException(
                sprintf('The target path %s does not exists', $targetPath)
            );
        }

        try {
            $this->fileSystem->ensureDirectoryExists(\dirname($linkPath));
        } catch (\RuntimeException $exception) {
            throw new LinkDirectoryError($exception->getMessage(), $exception->getCode(), $exception);
        }

        if (is_link($linkPath) && realpath(readlink($linkPath)) === $targetPath) {
            $this->event->getIO()->write(
                sprintf(
                    '  Symlink <comment>%s</comment> to <comment>%s</comment> already created',
                    $target,
                    $link
                )
            );
            return null;
        }

        return (new Symlink())
            ->setTarget($targetPath)
            ->setLink($linkPath)
            ->setAbsolutePath($this->getConfig(static::ABSOLUTE_PATH, $linkData, false))
            ->setForceCreate($this->getConfig(static::FORCE_CREATE, $linkData, false));
    }
142154
function link($target, $link)
    {
        $this->files->ensureDirExists(
            $linkPath = $this->sitesPath(), user()
        );

        $this->config->prependPath($linkPath);

        $this->files->symlinkAsUser($target, $linkPath.'/'.$link);

        return $linkPath.'/'.$link;
    }
462164
protected function symlink($target, $link)
    {
        $fs = FileSystem::getFileSystem();

        if ($this->isRelative()) {
            $link = (new PhingFile($link))->getAbsolutePath();
            $target = rtrim($this->makePathRelative($target, dirname($link)), '/');
        }

        if (is_link($link) && @readlink($link) == $target) {
            $this->log('Link exists: ' . $link, Project::MSG_INFO);

            return true;
        }

        if (file_exists($link) || is_link($link)) {
            if (!$this->getOverwrite()) {
                $this->log('Not overwriting existing link ' . $link, Project::MSG_ERR);

                return false;
            }

            if (is_link($link) || is_file($link)) {
                $fs->unlink($link);
                $this->log('Link removed: ' . $link, Project::MSG_INFO);
            } else {
                $fs->rmdir($link, true);
                $this->log('Directory removed: ' . $link, Project::MSG_INFO);
            }
        }

        $this->log('Linking: ' . $target . ' to ' . $link, Project::MSG_INFO);

        return $fs->symlink($target, $link);
    }
63682
def symlink(self, source, target):
        ''

        return self.operations('symlink', target.decode(self.encoding),
                                          source.decode(self.encoding))
1019773
public function ensureSymlinkExists($sourcePath, $symlinkPath)
    {
        if (!is_link($symlinkPath)) {
            $this->ensureDirectoryExists(dirname($symlinkPath));

            return symlink($sourcePath, $symlinkPath);
        }

        return false;
    }
476347
public void symlink(String path, String link) throws SftpStatusException,
			SshException {
		String actualPath = resolveRemotePath(path);
		String actualLink = resolveRemotePath(link);

		sftp.createSymbolicLink(actualLink, actualPath);
	}
685777
private function symlink($source, $target)
	{
		if (file_exists($target))
		{
			if (is_dir($target))
			{
				$this->_deleteDir($target);
			}
			else
			{
				unlink($target);
			}
		}

		try
		{
			$this->taskFileSystemStack()
				->symlink($source, $target)
				->run();
		}
		catch (Exception $e)
		{
			$this->say('Error symlinking: ' . $e->message());
		}
	}
258583
function symlink($target, $link)
    {
        if (!($this->bitmap & SSH2::MASK_LOGIN)) {
            return false;
        }

        //$target = $this->_realpath($target);
        $link = $this->_realpath($link);

        $packet = pack('Na*Na*', strlen($target), $target, strlen($link), $link);
        if (!$this->_send_sftp_packet(NET_SFTP_SYMLINK, $packet)) {
            return false;
        }

        $response = $this->_get_sftp_packet();
        if ($this->packet_type != NET_SFTP_STATUS) {
            user_error('Expected SSH_FXP_STATUS');
            return false;
        }

        if (strlen($response) < 4) {
            return false;
        }
        extract(unpack('Nstatus', $this->_string_shift($response, 4)));
        if ($status != NET_SFTP_STATUS_OK) {
            $this->_logError($response, $status);
            return false;
        }

        return true;
    }
248716
public function symlink($originDir, $targetDir, $relative = false)
    {
        if ($relative) {
            $this->filesystem->mkdir(dirname($targetDir));
            $originDir = $this->filesystem->makePathRelative($originDir, realpath(dirname($targetDir)));
        }
        $this->filesystem->symlink($originDir, $targetDir);

        if (!file_exists($targetDir)) {
            throw new \Exception(
                sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir),
                0,
                null
            );
        }
    }
16029
public static function create(string $link = '', string $target = ''): bool
    {
        $ret = true;
        $link = static::normalizePath($link);
        $target = static::normalizePath($target);

        if (static::verifyPath($link) && static::verifyPath($target) && Directory::create(\dirname($link)) &&
            !\file_exists($link) && \file_exists($target)) {

            $ret = @\symlink($target, $link);
            @\chmod($link, static::$newSymlinkMode);
        }

        return $ret;
    }
1161278
protected function symlinkLegacyExtensionSiteAccesses(string $legacyExtensionPath, OutputInterface $output): void
    {
        $legacyRootDir = $this->getContainer()->getParameter('ezpublish_legacy.root_dir');

        /** @var \DirectoryIterator[] $directories */
        $directories = [];

        $path = $legacyExtensionPath . '/root_' . $this->environment . '/settings/siteaccess/';
        if ($this->fileSystem->exists($path)) {
            $directories[] = new DirectoryIterator($path);
        }

        $path = $legacyExtensionPath . '/root/settings/siteaccess/';
        if ($this->fileSystem->exists($path)) {
            $directories[] = new DirectoryIterator($path);
        }

        $processedSiteAccesses = [];
        foreach ($directories as $directory) {
            foreach ($directory as $item) {
                if (!$item->isDir() || $item->isDot()) {
                    continue;
                }

                // We want root_* to have priority, so any siteaccess which we already "processed" will be skipped
                if (!in_array($item->getBasename(), $processedSiteAccesses, true)) {
                    $this->verifyAndSymlinkDirectory(
                        $item->getPathname(),
                        $legacyRootDir . '/settings/siteaccess/' . $item->getBasename(),
                        $output
                    );

                    $processedSiteAccesses[] = $item->getBasename();
                }
            }
        }
    }
1061114
protected function createFolders()
    {
        $dir    = null;
        $target = $this->getTargetDirectory();

        /** @noinspection IsEmptyFunctionUsageInspection */
        if (!empty($target)) {
            $dir = rtrim($target, '/') . DIRECTORY_SEPARATOR;
            $this->setTarget($dir);
        }

        if ($dir !== null && !is_dir($dir) && $this->isAllowCreateFolders()) {
            /** @noinspection NotOptimalIfConditionsInspection */
            /** @noinspection PhpUsageOfSilenceOperatorInspection */
            if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
                throw new Exception\NoSuchDirectoryException(
                    sprintf('Directory %s does not exists.', $dir)
                );
            }
        }
    }
296046
private static function createSymlink($symlinkTarget, $symlinkName)
    {
        $processBuilder = new ProcessBuilder(array('rm', '-rf', $symlinkTarget));
        $process = $processBuilder->getProcess();
        $process->run();

        if (symlink($symlinkName, $symlinkTarget) === false) {
            throw new \Exception('Error occured when trying to create a symlink.');
        }
    }
1070267
def replacing_symlink(source, link_name):
    
    with make_tmp_name(link_name) as tmp_link_name:
        os.symlink(source, tmp_link_name)
        replace_file_or_dir(link_name, tmp_link_name)