/** * Copies this file to the specified file instance. * * @param MCE_File $dest File to copy to. */ public function copyTo(MOXMAN_Vfs_IFile $dest) { if ($this->exists() && $this->isDirectory()) { if (!$this->isFileOrEmptyDir()) { throw new MOXMAN_Exception("Copy non empty folders not supported by S3."); } else { $dest->mkdir(); return; } } if ($dest instanceof MOXMAN_AmazonS3_File) { $fromPath = $this->getInternalPath(); $toPath = $dest->getInternalPath(); if ($this->isDirectory()) { $fromPath .= "/"; $toPath .= "/"; } $this->getFileSystem()->getClient()->copy($fromPath, $toPath); $dest->removeStatCache(); } else { $fromStream = $this->open("rb"); $toStream = $dest->open("wb"); while (($buff = $fromStream->read(8192)) !== "") { $toStream->write($buff); } $fromStream->close(); $toStream->close(); } }