zoukankan      html  css  js  c++  java
  • 无限级COPY目录或文件

    1. /***
    2. * Finished: 2007-05-22
    3. * COPY files or folder
    4. */
    5. // example
    6. wlccopy('../test', '../bac');
    7. /**
    8. * copy files or folder
    9. * notice: $path2 not in $path1
    10. */
    11. function wlccopy($path1,$path2)
    12. {
    13.     if(@is_dir($path1)){
    14.         @mkdir($path2, 0777);
    15.         @chmod($path2, 0777);
    16.         $dir=@opendir($path1);
    17.  
    18.         while($file=@readdir($dir)){ 
    19.             if($file=="." || $file==".."){
    20.                 continue;
    21.             }elseif(@is_file($path1, $file)){
    22.                 @copy("$path1/$file", "$path2/$file");
    23.             }else{
    24.                 wlccopy("$path1/$file", "$path2/$file");
    25.             }
    26.         }
    27.         @closedir($dir);
    28.     } else {
    29.         if(@copy($path1,$path2)){   
    30.             return 1;
    31.         }else {
    32.             return 0;
    33.         }
    34.     }
    35. }
  • 相关阅读:
    Redis基础用法
    SpringCloud
    Excel数据导入数据库
    MySQL数据库汇总
    Java8stream表达式
    LocalDateTime&LocalDate&LocalTime
    深入理解Java中的锁
    数据集合
    平台介绍
    dubbo源码阅读之自适应扩展
  • 原文地址:https://www.cnblogs.com/studio313/p/1061350.html
Copyright © 2011-2022 走看看