Пример #1
0
 /**
  * 删除文件夹
  */
 public static function delete($path, $deleteSelf = true)
 {
     $path = path::decode($path);
     // 判断是否是文件夹
     if (!is_dir($path)) {
         return false;
     }
     // 删除文件夹下的全部文件
     $files = folder::files($path, false, true, '', array());
     if (count($files)) {
         if (file::delete($files) !== true) {
             return false;
         }
     }
     // 删除全部子文件夹
     $folders = folder::folders($path, false, true, '.', array());
     foreach ($folders as $folder) {
         if (folder::delete($folder) !== true) {
             return false;
         }
     }
     //删除自身,如果不删除自身,则为清理文件夹
     if ($deleteSelf === true) {
         if (@rmdir($path)) {
             return true;
         }
         return false;
     }
     return true;
 }