zoukankan      html  css  js  c++  java
  • PHP文件夹文件拷贝/复制函数 dir_copy($src = '', $dst = '')

    /*
     * 文件夹文件拷贝
     *
     * @param string $src 来源文件夹
     * @param string $dst 目的地文件夹
     * @return bool
     */
    function dir_copy($src = '', $dst = '')
    {
        if (empty($src) || empty($dst))
        {
            return false;
        }
        $dir = opendir($src);
        dir_mkdir($dst);
        while (false !== ($file = readdir($dir)))
        {
            if (($file != '.') && ($file != '..'))
            {
                if (is_dir($src . '/' . $file))
                {
                    dir_copy($src . '/' . $file, $dst . '/' . $file);
                }
                else
                {
                    copy($src . '/' . $file, $dst . '/' . $file);
                }
            }
        }
        closedir($dir);
        return true;
    }
     
    /**
     * 创建文件夹
     *
     * @param string $path 文件夹路径
     * @param int $mode 访问权限
     * @param bool $recursive 是否递归创建
     * @return bool
     */
    function dir_mkdir($path = '', $mode = 0777, $recursive = true)
    {
        clearstatcache();
        if (!is_dir($path))
        {
            mkdir($path, $mode, $recursive);
            return chmod($path, $mode);
        }
     
        return true;
    }
  • 相关阅读:
    基数排序学习
    桶排序学习
    计数排序-不基于比较O(n)
    基尼系数
    拉普拉斯进行特征选择
    int ,long long等范围
    Codeforces780C
    51 Nod 1119
    字典树入门
    POJ 2531 暴力深搜
  • 原文地址:https://www.cnblogs.com/qingsong/p/5002529.html
Copyright © 2011-2022 走看看