From e3a93d5c84e5c91711998f2bbbe2048363703edc Mon Sep 17 00:00:00 2001 From: "Johannes M. Schmitt" Date: Fri, 10 Aug 2012 10:14:02 +0200 Subject: [PATCH] switched to use the ProcessExecutor utility class --- src/Composer/Util/Filesystem.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Composer/Util/Filesystem.php b/src/Composer/Util/Filesystem.php index 59239671f..f2b06190c 100644 --- a/src/Composer/Util/Filesystem.php +++ b/src/Composer/Util/Filesystem.php @@ -18,6 +18,13 @@ namespace Composer\Util; */ class Filesystem { + private $processExecutor; + + public function __construct(ProcessExecutor $executor = null) + { + $this->processExecutor = $executor ?: new ProcessExecutor(); + } + public function removeDirectory($directory) { if (!is_dir($directory)) { @@ -62,9 +69,14 @@ class Filesystem return; } - exec('mv '.escapeshellarg($source).' '.escapeshellarg($target), $output, $returnCode); - if (0 !== $returnCode) { - throw new \RuntimeException(sprintf('Could not rename "%s" to "%s".', $source, $target)); + // We do not use PHP's "rename" function here since it does not support + // the case where $source, and $target are located on different partitions. + if (0 !== $this->processExecutor->execute('mv '.escapeshellarg($source).' '.escapeshellarg($target))) { + if (true === @rename($source, $target)) { + return; + } + + throw new \RuntimeException(sprintf('Could not rename "%s" to "%s".', $source, $target)); } }