Skip to content

Commit

Permalink
Use OS mv utility on Linux systems. Fixes symfony#12533.
Browse files Browse the repository at this point in the history
  • Loading branch information
RoSk0 committed Nov 26, 2014
1 parent 6a63cc5 commit 0f37c57
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,16 @@ public function rename($origin, $target, $overwrite = false)
throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
}

if (true !== @rename($origin, $target)) {
throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
if (defined('PHP_WINDOWS_VERSION_BUILD') || ! function_exists('exec')) {
if (true !== @rename($origin, $target)) {
throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
}
}
else {
exec('mv ' . escapeshellarg($origin) . ' ' . escapeshellarg($target), $output, $returnCode);
if (0 !== $returnCode) {
throw new \RuntimeException(sprintf('Could not rename "%s" to "%s".', $origin, $target));
}
}
}

Expand Down

0 comments on commit 0f37c57

Please sign in to comment.