mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
修复clear指令无法删除多级目录下文件的问题
This commit is contained in:
@@ -28,17 +28,27 @@ class Clear extends Command
|
||||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
$path = $input->getOption('path') ?: RUNTIME_PATH;
|
||||
$path = $input->getOption('path') ?: RUNTIME_PATH;
|
||||
|
||||
if (is_dir($path)) {
|
||||
$this->clearPath($path);
|
||||
}
|
||||
|
||||
$output->writeln("<info>Clear Successed</info>");
|
||||
}
|
||||
|
||||
protected function clearPath($path)
|
||||
{
|
||||
$path = realpath($path) . DS;
|
||||
$files = scandir($path);
|
||||
if ($files) {
|
||||
foreach ($files as $file) {
|
||||
if ('.' != $file && '..' != $file && is_dir($path . $file)) {
|
||||
array_map('unlink', glob($path . $file . '/*.*'));
|
||||
$this->clearPath($path . $file);
|
||||
} elseif ('.gitignore' != $file && is_file($path . $file)) {
|
||||
unlink($path . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
$output->writeln("<info>Clear Successed</info>");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user