/** * Рекурсивное копирование директории. * * * */ public function copy(iDir $target, $createDirectory = true) { if (!$target->canWrite()) { throw new FileSystemException('Copy: target directory isnt writable: ' . $target); } if ($createDirectory) { $target = $target->mkdir($this->getName()); } $list = $this->ls(null, Dir::LS_BOTH, GLOB_NOSORT); foreach ($list as $o) { //$name = $o->getName(); //print_pre('>>> '.(is_dir($o)?" D ":"").$name); if ($o instanceof File) { $o->copy($target->getFile($o->getName())); } elseif ($o instanceof Dir) { $o->copy($target, true); } else { throw new FileSystemException('Unsupported object class: ' . get_class($o)); } } return $target; }