diff --git a/extend/catcher/CatchConsole.php b/extend/catcher/CatchConsole.php new file mode 100644 index 0000000..ef90e0a --- /dev/null +++ b/extend/catcher/CatchConsole.php @@ -0,0 +1,10 @@ +files($path); + + $dirs = $this->dirs($path); + + foreach ($dirs as $dir) { + $files = array_merge($files, $this->allFiles($dir)); + } + + return $files; + } + + /** + * 获取文件夹下的文件 + * + * @time 2020年07月02日 + * @param $path + * @return array + */ + public function files($path) + { + $files = []; + + $fileSystemIterator = new \FilesystemIterator($path); + + foreach ($fileSystemIterator as $fileSystem) { + if (!$fileSystem->isDir()) { + $files[] = $fileSystem->getPathName(); + } + } + + return $files; + } + + /** + * 获取文件夹 + * + * @time 2020年07月02日 + * @param $path + * @return array + */ + public function dirs($path) + { + $dirs = []; + + $fileSystemIterator = new \FilesystemIterator($path); + + foreach ($fileSystemIterator as $fileSystem) { + if ($fileSystem->isDir()) { + $dirs[] = $fileSystem->getPathname(); + } + } + + return $dirs; + } +} \ No newline at end of file