From e35b14a883d8b77a2c8b179b23c589ee9967aea8 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Thu, 2 Jul 2020 13:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=96=87=E4=BB=B6=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/catcher/CatchConsole.php | 10 ++++ extend/catcher/library/FileSystem.php | 78 +++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 extend/catcher/CatchConsole.php create mode 100644 extend/catcher/library/FileSystem.php 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