1
0
Fork 0

Fixed Windows detection based on #4873 and suppressed some console output in removeJunction.

pull/4845/head
Niels Keurentjes 2016-02-05 11:27:41 +01:00
parent 582e4796a3
commit 54c079b559
2 changed files with 7 additions and 6 deletions

View File

@ -13,6 +13,7 @@
namespace Composer\Downloader; namespace Composer\Downloader;
use Composer\Package\PackageInterface; use Composer\Package\PackageInterface;
use Composer\Util\Platform;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
@ -48,8 +49,8 @@ class PathDownloader extends FileDownloader
} }
try { try {
if (defined('PHP_WINDOWS_VERSION_BUILD')) { if (Platform::isWindows()) {
// Implement symlinks as junctions on Windows, with magic shell hackery // Implement symlinks as NTFS junctions on Windows
$this->filesystem->junction($realUrl, $path); $this->filesystem->junction($realUrl, $path);
$this->io->writeError(sprintf(' Junctioned from %s', $url)); $this->io->writeError(sprintf(' Junctioned from %s', $url));

View File

@ -590,7 +590,7 @@ class Filesystem
*/ */
public function junction($target, $junction) 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__)); throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
} }
if (!is_dir($target)) { if (!is_dir($target)) {
@ -612,7 +612,7 @@ class Filesystem
*/ */
public function isJunction($junction) public function isJunction($junction)
{ {
if (!defined('PHP_WINDOWS_VERSION_BUILD')) { if (!Platform::isWindows()) {
return false; return false;
} }
if (!is_dir($junction) || is_link($junction)) { if (!is_dir($junction) || is_link($junction)) {
@ -631,7 +631,7 @@ class Filesystem
*/ */
public function removeJunction($junction) public function removeJunction($junction)
{ {
if (!defined('PHP_WINDOWS_VERSION_BUILD')) { if (!Platform::isWindows()) {
return false; return false;
} }
$junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR); $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)); 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)); $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape($junction));
return ($this->getProcess()->execute($cmd) === 0); return ($this->getProcess()->execute($cmd, $output) === 0);
} }
} }