From dd6ac78536dbea005f62f959d0e23ea05674c69f Mon Sep 17 00:00:00 2001 From: c33s Date: Sun, 27 Mar 2016 01:26:21 +0100 Subject: [PATCH] poc example --- .../Component/Filesystem/Filesystem.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index dcef5c64aeb99..cd84ad41b077f 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -12,6 +12,8 @@ namespace Symfony\Component\Filesystem; use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Process\ExecutableFinder; +use Symfony\Component\Process\ProcessBuilder; /** * Provides basic utility to manipulate the file system. @@ -311,6 +313,13 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) } } + + if ($this->existsJunctionExecutable()) { + $this->createWindowsJunction($originDir, $targetDir); + $ok = true; + } + + if (!$ok && true !== @symlink($originDir, $targetDir)) { $report = error_get_last(); if (is_array($report)) { @@ -322,6 +331,35 @@ public function symlink($originDir, $targetDir, $copyOnWindows = false) } } + protected function existsJunctionExecutable() + { + if ($this->getJunctionExecutable()) { + return true; + } + + return false; + } + + protected function getJunctionExecutable() + { + $executableFinder = new ExecutableFinder(); + + return $executableFinder->find('junction'); + } + + protected function createWindowsJunction($originDir, $targetDir) + { + $junction = $this->getJunctionExecutable(); + + $processBuilder = new ProcessBuilder(); + $process = $processBuilder + ->setPrefix($junction) + ->setArguments(array($targetDir, $originDir)) + ->getProcess() + ; + $process->run(); + } + /** * Given an existing path, convert it to a path relative to a given starting path. *