Beispiel #1
0
 /**
  * Copy Dir
  * Copy a directory and all its contents
  *
  * @param string $fromDir Full path to dir to copy
  * @param string $toDir Full path to new location of copy
  * @return bool True on pass, false on fail
  */
 public static function copy_dir($fromDir, $toDir)
 {
     $file_tools = new RazorFileTools(get_class($this));
     $result = false;
     $readFromDir = $fromDir;
     $readToDir = $toDir;
     $file_tools->create_dir($readToDir);
     if (is_dir($readFromDir)) {
         $filesArray = array();
         $filesArray = $file_tools->read_dir_contents($readFromDir);
         // do recursive delete if dir contains files //
         foreach ($filesArray as $name) {
             if (is_dir($readFromDir . '/' . $name)) {
                 $result = self::copy_dir($fromDir . '/' . $name, $toDir . '/' . $name);
             } elseif (file_exists($readFromDir . '/' . $name)) {
                 $result = self::copy_file($fromDir . '/' . $name, $toDir . '/' . $name, false);
             }
         }
     }
     return $result;
 }