switched to use the ProcessExecutor utility class

main
Johannes M. Schmitt 12 years ago
parent 2a6b12fb65
commit e3a93d5c84

@ -18,6 +18,13 @@ namespace Composer\Util;
*/ */
class Filesystem class Filesystem
{ {
private $processExecutor;
public function __construct(ProcessExecutor $executor = null)
{
$this->processExecutor = $executor ?: new ProcessExecutor();
}
public function removeDirectory($directory) public function removeDirectory($directory)
{ {
if (!is_dir($directory)) { if (!is_dir($directory)) {
@ -62,9 +69,14 @@ class Filesystem
return; return;
} }
exec('mv '.escapeshellarg($source).' '.escapeshellarg($target), $output, $returnCode); // We do not use PHP's "rename" function here since it does not support
if (0 !== $returnCode) { // the case where $source, and $target are located on different partitions.
throw new \RuntimeException(sprintf('Could not rename "%s" to "%s".', $source, $target)); 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));
} }
} }

Loading…
Cancel
Save