选择语言 :

 Core_File::remove_dir

循环删除目录下的所有目录和文件,多服务器可以自动同步

boolean Core_File::remove_dir( string $dir [, string $storage = string(7) "default" ] )

参数列表

参数 类型 描述 默认值
$dir string Name
$storage string 物理存储组,不传则为默认 string(7) "default"
返回值
  • boolean
File: ./core/classes/file.class.php
public static function remove_dir($dir , $storage = 'default')
{
    $info = File::check_and_get_path($dir);

    if (File::can_do_run($storage))
    {
        if (!is_dir($dir))
        {
            return true;
        }

        $realpath = realpath($dir);

        if (!$realpath || in_array($realpath.DS, File::$sys_dir))
        {
            return true;
        }

        $handle = opendir($dir);
        while (($file = readdir($handle)) !== false)
        {
            if ( $file != '.' && $file != '..' )
            {
                $tmp_dir = $dir . DS . $file;
                is_dir($tmp_dir) ? File::remove_dir($tmp_dir) : @unlink($tmp_dir);
            }
        }

        closedir($handle);

        return @rmdir($dir);
    }
    else
    {
        return File::call_http_host($storage, 'file/remove_dir', $info[0], $info[1] );
    }
}