Create symlink

@param string $target Target directory
@param string $link Link name
@return bool
320638
protected function _createSymlink($target, $link)
    {
        // @codingStandardsIgnoreStart
        $result = @symlink($target, $link);
        // @codingStandardsIgnoreEnd

        if ($result) {
            $this->out('Created symlink ' . $link);

            return true;
        }

        return false;
    }
640158
public function createRelative($directory, $target, $link)
	{
		if (!is_dir($directory)) {
			$this->error("Directory '$directory' not found.");
		}
		if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
			$cmd = 'cd ' . escapeshellarg($directory) . ' && mklink ' . ' /D ' . escapeshellarg($link) . ' ' . escapeshellarg($target);
		} else {
			$cmd = 'cd ' . escapeshellarg($directory) . ' && ln -s ' . escapeshellarg($target) . ' ' . escapeshellarg($link);
		}
		$command = new Commands\Exec();
		$command->setCommand($cmd);
		$result = $command->execute();
		if ($result->getResult() !== 0) {
			$this->error("Cannot create symlink '$target' - '$link' in directory '$directory'.");
		}
		return $result;
	}
144729
def symlink(target, linkname):
    
    target = os.path.abspath(target)
    linkname = os.path.abspath(linkname)
    if not os.path.exists(target):
        raise ValueError("target {} not found".format(target))

    link_dir = os.path.dirname(linkname)
    if not os.path.exists(link_dir):
        os.makedirs(link_dir)

    run(['ln', '-s', '-f', target, linkname])
    return linkname
289385
protected static function createLink( $source, $target )
	{
		if( file_exists( $target ) === false && @symlink( $source, $target ) === false )
		{
			$source = realpath( __DIR__ . '/' . $source );

			if( symlink( $source, $target ) === false ) {
				throw new \RuntimeException( sprintf( 'Failed to create symlink for "%1$s" to "%2$s"', $source, $target ) );
			}
		}
	}
378285
protected function copyDirectory($source, $target)
    {
        new Rah_Eien_Action_Stat($source, 'rd');
        new Rah_Eien_Action_Stat($target, 'wd');

        $files = new RecursiveDirectoryIterator($source);
        $file = new RecursiveIteratorIterator($files, RecursiveIteratorIterator::SELF_FIRST);

        while ($file->valid())
        {
            if ($file->isDot() === false)
            {
                $name = $target.'/'.$file->getSubPathName();

                if ($file->isDir())
                {
                    if (@mkdir($name) === false)
                    {
                        throw new Rah_Eien_Exception('Unable to create a directory: '.$name);
                    }
                }
                else
                {
                    $this->copyFile($file->getPathname(), $name);
                }
            }

            $file->next();
        }
    }
424292
private function mkdir($target)
    {
        if (\is_dir($target)) {
            return;
        }

        if (! $this->file->mkdir($target)) {
            $this->output->writeln("<error>[$target] could not be created. Please check directory permissions.</error>");
        }
    }
175871
def create_symlink(source, link_name):
    
    os_symlink = getattr(os, "symlink", None)
    if isinstance(os_symlink, collections.Callable):
        os_symlink(source, link_name)
    else:
        import ctypes
        csl = ctypes.windll.kernel32.CreateSymbolicLinkW
        csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
        csl.restype = ctypes.c_ubyte
        flags = 1 if os.path.isdir(source) else 0
        if csl(link_name, source, flags) == 0:
            raise ctypes.WinError()
464239
protected function createLink($source, $target)
    {
        $success = $this->filesystem->relativeSymlink($source, $target);
        if (!$success) {
            throw new RuntimeException("Could not create symlink at $target");
        }
    }
192106
public static int symLink(String target, String linkname) throws IOException{
    String cmd = "ln -s " + target + " " + linkname;
    Process p = Runtime.getRuntime().exec(cmd, null);
    int returnVal = -1;
    try{
      returnVal = p.waitFor();
    } catch(InterruptedException e){
      //do nothing as of yet
    }
    return returnVal;
  }
898468
public function buildMetaLink($output, Link $link)
    {
        $name = $link->getName();

        $output->$name = new \stdClass();
        $output->$name->href = $link->getHref();
        $output->$name->meta = (object) $link->getMeta();

        return $output;
    }
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)
        );
    }
716292
public void symlinkTo(final String target, final TaskListener listener) throws IOException, InterruptedException {
        act(new SymlinkTo(target, listener));
    }
315065
public function link($target, $link)
    {
        if (! windows_os()) {
            return symlink($target, $link);
        }

        $mode = $this->isDirectory($target) ? 'J' : 'H';

        exec("mklink /{$mode} \"{$link}\" \"{$target}\"");
    }
1322320
public Anchor createAnchor(String href, String target) {
    return this.add(new Anchor(href, target));
  }
746304
public static function RecursiveCopyDir($source, $target)
    {
        $source_dir = opendir($source);

        //Check if source directory exists
        if(!$source_dir)
        {
            return false;
        }

        //Create target directory in case it doesnt exist
        if(!file_exists($target))
        {
            self::MakeDir($target, 0755, true);
        }

        while(($item = readdir($source_dir)) !== false)
        {
            $source_full_path = $source . "/" . $item;
            $target_full_path = $target . "/" . $item;

            if($item != "." && $item != "..")
            {
                //copy source files
                if(is_file($source_full_path))
                {
                    if(!copy($source_full_path, $target_full_path))
                    {
                        return false;
                    }
                }
                else if(is_dir($source_full_path))
                {
                    self::RecursiveCopyDir($source_full_path, $target_full_path);
                }
            }
        }

        closedir($source_dir);

        return true;
    }
614917
protected function verifyAndSymlinkDirectory(string $source, string $destination, OutputInterface $output): void
    {
        if ($this->fileSystem->exists($destination) && !is_link($destination)) {
            $output->writeln('<comment>' . basename($destination) . '</comment> already exists in <comment>' . dirname($destination) . '/</comment> and is not a symlink. Skipping...');

            return;
        }

        if ($this->forceSymlinks && is_link($destination)) {
            $this->fileSystem->remove($destination);
        }

        if ($this->fileSystem->exists($destination)) {
            $output->writeln('Skipped creating the symlink for <comment>' . basename($destination) . '</comment> in <comment>' . dirname($destination) . '/</comment>. Symlink already exists!');

            return;
        }

        $this->fileSystem->symlink(
            $this->fileSystem->makePathRelative(
                $source,
                realpath(dirname($destination))
            ),
            $destination
        );
    }
850361
private function symlink(string $originDir, string $targetDir, bool $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 IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
        }
    }