Fixes #15335: Added FileHelper::unlink() that works well under all OSes

This commit is contained in:
Alexander Makarov
2017-12-11 22:29:31 +03:00
committed by GitHub
parent adc441de83
commit efac23dde7
4 changed files with 38 additions and 31 deletions

View File

@ -250,13 +250,13 @@ class DevController extends Controller
{
if (is_link($link = "$dir/vendor/yiisoft/yii2")) {
$this->stdout("Removing symlink $link.\n");
$this->unlink($link);
FileHelper::unlink($link);
}
$extensions = $this->findDirs("$dir/vendor/yiisoft");
foreach ($extensions as $ext) {
if (is_link($link = "$dir/vendor/yiisoft/yii2-$ext")) {
$this->stdout("Removing symlink $link.\n");
$this->unlink($link);
FileHelper::unlink($link);
}
}
}
@ -293,20 +293,6 @@ class DevController extends Controller
}
}
/**
* Properly removes symlinked directory under Windows, MacOS and Linux.
*
* @param string $file path to symlink
*/
protected function unlink($file)
{
if (is_dir($file) && DIRECTORY_SEPARATOR === '\\') {
rmdir($file);
} else {
unlink($file);
}
}
/**
* Get a list of subdirectories for directory specified.
* @param string $dir directory to read