protected function copyFrom($volume, $src, $destination, $name)
{
if (($source = $volume->file($src)) == false) {
return $this->setError(elFinder::ERROR_COPY, '#' . $src, $volume->error());
}
$errpath = $volume->path($src);
if (!$this->nameAccepted($source['name'])) {
return $this->setError(elFinder::ERROR_COPY, $errpath, elFinder::ERROR_INVALID_NAME);
}
if (!$source['read']) {
return $this->setError(elFinder::ERROR_COPY, $errpath, elFinder::ERROR_PERM_DENIED);
}
if ($source['mime'] == 'directory') {
$stat = $this->stat($this->_joinPath($destination, $name));
$this->clearcache();
if ((!$stat || $stat['mime'] != 'directory') && !$this->_mkdir($destination, $name)) {
return $this->setError(elFinder::ERROR_COPY, $errpath);
}
$path = $this->_joinPath($destination, $name);
foreach ($volume->scandir($src) as $entr) {
if (!$this->copyFrom($volume, $entr['hash'], $path, $entr['name'])) {
return false;
}
}
} else {
// $mime = $source['mime'];
// $w = $h = 0;
if ($dim = $volume->dimensions($src)) {
$s = explode('x', $dim);
$source['width'] = $s[0];
$source['height'] = $s[1];
}
if (($fp = $volume->open($src)) == false || ($path = $this->_save($fp, $destination, $name, $source)) == false) {
$fp && $volume->close($fp, $src);
return $this->setError(elFinder::ERROR_COPY, $errpath);
}
$volume->close($fp, $src);
}
return $path;
}