public mixed
copy
(mixed $src, mixed $dest, mixed $context = null, mixed $usePrefix = true, mixed $relative = false)
/**
* Copy a file from src to dest
*
* @param string $src The file path to copy from.
* @param string $dest The file path to copy to.
* @param resource $context A valid context resource (optional) created with stream_context_create.
* @param boolean $usePrefix Controls the use of a prefix (optional).
* @param boolean $relative Determines if the filename given is relative. Relative paths do not have JPATH_ROOT stripped.
*
* @return mixed
*
* @since 1.7.0
*/
public function copy($src, $dest, $context = null, $usePrefix = true, $relative = false)
{
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$chmodDest = $this->_getFilename($dest, 'w', $usePrefix, $relative);
// Since we're going to open the file directly we need to get the filename.
// We need to use the same prefix so force everything to write.
$src = $this->_getFilename($src, 'w', $usePrefix, $relative);
$dest = $this->_getFilename($dest, 'w', $usePrefix, $relative);
if ($context) {
// Use the provided context
$res = @copy($src, $dest, $context);
} elseif ($this->context) {
// Use the objects context
$res = @copy($src, $dest, $this->context);
} else {
// Don't use any context
$res = @copy($src, $dest);
}
if (!$res && $php_errormsg) {
$this->setError($php_errormsg);
} else {
$this->chmod($chmodDest);
}
// Restore error tracking to what it was before
ini_set('track_errors', $track_errors);
return $res;
}