/** * Copy directory to another directory location * * @param \Drone\Filesystem\Directory $directory (directory object with copy location) * @return boolean */ public function copy(\Drone\Filesystem\Directory $directory, $chmod = 0644) { if (!$this->__isDir()) { return false; } if (!$directory->create($chmod)) { $this->error = 'Failed to create new directory \'' . $directory->getPath() . '\''; return false; } foreach ($this->read(false, true) as $asset) { if ($asset['type'] === 'dir') { $dir = new Directory($this->_path . $asset['name'], false); if (!$dir->copy(new Directory($directory->getPath() . $asset['name'], false), $chmod)) { $this->error = 'Failed to create new subdirectory \'' . $dir->getPath() . '\' (' . $dir->error . '), try elevated chmod'; return false; } } else { $file = new File($this->_path . $asset['name'], false); if (!$file->copy(new File($directory->getPath() . $asset['name'], false), $chmod)) { $this->error = 'Failed to create new file \'' . $file->getPath() . '\' (' . $file->error . '), try elevated chmod'; return false; } } } return true; }