diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index b4f52f0b0..6a65e89af 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -13,6 +13,7 @@ namespace Composer\Downloader; use Composer\Package\PackageInterface; +use Composer\Util\Platform; use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; @@ -48,8 +49,8 @@ class PathDownloader extends FileDownloader } try { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - // Implement symlinks as junctions on Windows, with magic shell hackery + if (Platform::isWindows()) { + // Implement symlinks as NTFS junctions on Windows $this->filesystem->junction($realUrl, $path); $this->io->writeError(sprintf(' Junctioned from %s', $url)); diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 8e7ac3d04..4b69a85c9 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -590,7 +590,7 @@ class Filesystem */ public function junction($target, $junction) { - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if (!Platform::isWindows()) { throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__)); } if (!is_dir($target)) { @@ -612,7 +612,7 @@ class Filesystem */ public function isJunction($junction) { - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if (!Platform::isWindows()) { return false; } if (!is_dir($junction) || is_link($junction)) { @@ -631,7 +631,7 @@ class Filesystem */ public function removeJunction($junction) { - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { + if (!Platform::isWindows()) { return false; } $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR); @@ -639,6 +639,6 @@ class Filesystem throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction)); } $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape($junction)); - return ($this->getProcess()->execute($cmd) === 0); + return ($this->getProcess()->execute($cmd, $output) === 0); } }