From 05cbf1c1464d993881c0ac547ecbe98e1d39a96f Mon Sep 17 00:00:00 2001 From: shuipf Date: Wed, 30 Mar 2016 13:30:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DFile=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E4=B8=8B=EF=BC=8Cclear=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit linux可能出现 . 或者 .. 特殊目录,在进行is_dir时,会报错 --- library/think/cache/driver/File.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/library/think/cache/driver/File.php b/library/think/cache/driver/File.php index fddd9df0..bf2fd1d7 100644 --- a/library/think/cache/driver/File.php +++ b/library/think/cache/driver/File.php @@ -186,18 +186,11 @@ class File */ public function clear() { - $path = $this->options['path']; - if ($dir = opendir($path)) { - while ($file = readdir($dir)) { - $check = is_dir($file); - if (!$check) { - $this->unlink($path . $file); - } - - } - closedir($dir); - return true; + $fileLsit = (array)glob($this->options['path'].'*'); + foreach ($fileLsit as $path) { + is_file($path) && unlink($path); } + return true; } /**