function Filesystem::rename
Same name in this branch
- 11.1.x vendor/symfony/filesystem/Filesystem.php \Symfony\Component\Filesystem\Filesystem::rename()
Return value
void
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Filesystem.php, line 416
Class
- Filesystem
- @author Jordi Boggiano <j.boggiano@seld.be> @author Johannes M. Schmitt <schmittjoh@gmail.com>
Namespace
Composer\UtilCode
public function rename(string $source, string $target) {
if (true === @rename($source, $target)) {
return;
}
if (!\function_exists('proc_open')) {
$this->copyThenRemove($source, $target);
return;
}
if (Platform::isWindows()) {
// Try to copy & delete - this is a workaround for random "Access denied" errors.
$result = $this->getProcess()
->execute([
'xcopy',
$source,
$target,
'/E',
'/I',
'/Q',
'/Y',
], $output);
// clear stat cache because external processes aren't tracked by the php stat cache
clearstatcache();
if (0 === $result) {
$this->remove($source);
return;
}
}
else {
// 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.
$result = $this->getProcess()
->execute([
'mv',
$source,
$target,
], $output);
// clear stat cache because external processes aren't tracked by the php stat cache
clearstatcache();
if (0 === $result) {
return;
}
}
$this->copyThenRemove($source, $target);
}