Copy the file.
@param  string $dst
@param  integer $mode
@return boolean     true for success, otherwise false
438163
public function copy($dst, $mode=null) {
		$dst = \Asgard\File\FileSystem::copy($this->src, $dst, $mode);
		if($dst) {
			$copy = clone $this;
			$copy->setSrc($dst);
			return $copy;
		}
		return false;
	}
241569
public function setTransferMode( $mode )
	{
		if( $mode != FTP_BINARY && $mode != FTP_ASCII )
			return FALSE;
		$this->mode	= $mode;
		return TRUE;
	}
756838
public function copy($dest, $overwrite = true)
    {
        if (!$this->exists() || is_file($dest) && !$overwrite) {
            return false;
        }

        return copy($this->path, $dest);
    }
361224
def copy(src, dst):
    
    if os.path.isdir(dst):
        dst = os.path.join(dst, os.path.basename(src))
    copyfile(src, dst)
    copymode(src, dst)
971999
public function autoOrient(string $src, string $dst)
    {
        if (!$dst) {
            $dst=$src;
        }
        return $this
        ->image($src)
        ->autoOrient()
        ->toFile($dst);
    }
1211510
public static function move(string $srcFile = '', string $dstFile = ''): bool
    {
        $srcFile = static::normalizePath($srcFile);
        $dstFile = static::normalizePath($dstFile);
        if (static::exists($srcFile) && !static::exists($dstFile) && static::verifyPath($dstFile)) {
            if (Directory::create(\dirname($dstFile))) {
                return @\rename($srcFile, $dstFile);
            }
        }
        return false;
    }
573693
public function copyToDFS( $srcFilePath, $dstFilePath = false )
    {
        $this->accumulatorStart();

        $srcFileSize = filesize( $srcFilePath );
        $srcFileHandle = fopen( $srcFilePath, 'rb' );
        if ( $srcFileHandle === false )
        {
            $this->accumulatorStop();
            eZDebug::writeError( "Error getting contents of file 'FS://$srcFilePath'.", __METHOD__ );
            return false;
        }

        if ( $dstFilePath === false )
        {
            $dstFilePath = $srcFilePath;
        }

        $dstFilePath = $this->makeDFSPath( $dstFilePath );
        $ret = $this->createFile( $dstFilePath, $srcFileHandle, true );
        if ( $ret )
        {
            // Double checking if the file has been correctly created
            clearstatcache( true, $dstFilePath );
            $dstFileSize = filesize( $dstFilePath );
            if ( $dstFileSize != $srcFileSize )
            {
                eZDebug::writeError( "Size ($dstFileSize) of written data for file FS://$dstFilePath does not match expected size of original DFS file ($srcFileSize)", __METHOD__ );
                $ret = false;
            }
        }

        $this->accumulatorStop();

        return $ret;
    }
1310774
public function copyTo($dest, $full = true)
    {
        if ($full) {
            if (strpos($this->path, DIRECTORY_SEPARATOR) !== false) {
                $folder = substr($this->path, (strrpos($this->path, DIRECTORY_SEPARATOR) + 1));
            } else {
                $folder = $this->path;
            }

            if (!file_exists($dest . DIRECTORY_SEPARATOR . $folder)) {
                mkdir($dest . DIRECTORY_SEPARATOR . $folder);
            }
            $dest = $dest . DIRECTORY_SEPARATOR . $folder;
        }

        return static::copy($this->path, $dest, true);
    }
23445
public function copyFromDFS( $srcFilePath, $dstFilePath = false )
    {
        $this->accumulatorStart();

        if ( $dstFilePath === false )
        {
            $dstFilePath = $srcFilePath;
        }
        $srcFilePath = $this->makeDFSPath( $srcFilePath );

        if ( file_exists( dirname( $dstFilePath ) ) )
        {
            $ret = copy( $srcFilePath, $dstFilePath );
            if ( $ret )
                $this->fixPermissions( $dstFilePath );
        }
        else
        {
            $ret = $this->createFile( $dstFilePath, fopen( $srcFilePath, 'rb' ) );
        }

        if ( $ret )
        {
            $ret = $this->copyTimestamp( $srcFilePath, $dstFilePath );
        }

        if ( !$ret && file_exists( $dstFilePath ) )
        {
            unlink( $dstFilePath );
        }

        $this->accumulatorStop();

        return $ret;
    }
1302458
protected function _mode($mode)
	{
		if ($mode == FTP_BINARY)
		{
			if (!$this->_putCmd('TYPE I', 200))
			{
				throw new FilesystemException(
					sprintf('%1$s: Bad response. Server response: %2$s [Expected: 200]. Mode sent: Binary', __METHOD__, $this->response)
				);
			}
		}
		else
		{
			if (!$this->_putCmd('TYPE A', 200))
			{
				throw new FilesystemException(
					sprintf('%1$s: Bad response. Server response: %2$s [Expected: 200]. Mode sent: ASCII', __METHOD__, $this->response)
				);
			}
		}

		return true;
	}
224571
public function copyFile($srcDir, $dstDir)
    {
        $this->returnCode = 'no';

        return $this->send('v-copy-fs-file', $this->userName, $srcDir, $dstDir);
    }
486904
public function replicate($src, $dst, $create = false, $continuous = false, $filter = null, array $params = array()) {
    $post = (object)array(
      'source'        => $this->_validator()->dbUrl($src),
      'target'        => $this->_validator()->dbUrl($dst),
      'continuous'    => $this->_validator()->boolean($continuous),
      'create_target' => $this->_validator()->boolean($create),
    );
    if (!empty($filter)) {
      $post->filter = $this->_validator()->filter($filter);
      if (!empty($params)) {
        $post->filterQueryParams = $params;
      }
    }
    return $this->_call(__FUNCTION__, self::METHOD_POST, '_replicate', array(), $post);
  }
106879
public static function copyDir($src, $dst, $fileMode = 0644)
    {
        $src = realpath($src);
        if (!is_readable($src)) {
            throw new Exception('Dir ' . $src . ' is not readable');
        }
        if (!is_dir($src)) {
            throw new Exception('' . $src . ' is not a directory');
        }

        if (!file_exists($dst)) {
            self::mkDir($dst);
        }
        $dst = realpath($dst);
        if (!is_readable($dst)) {
            throw new Exception('Dir ' . $dst . ' is not readable');
        }
        if (!is_dir($dst)) {
            throw new Exception('' . $dst . ' is not a directory');
        }

        foreach (self::listDir($src) as $file) {
            $fileName = basename($file);
            if ('.' == $fileName || '..' == $fileName) {
                continue;
            }
            if (!is_readable($file)) {
                throw new Exception($file . ' is not readable');
            }
            if (is_dir($file)) {
                self::copyDir($file, $dst . DS . $fileName);
            } else {
                self::copyFile($file, $dst, $fileMode);
            }
        }
    }
1368611
protected function _copyBlockPositions($dst, $src)
    {
        $this->loadModel('Block.BlockRegions');
        $dstTheme = plugin($dst);
        $newRegions = isset($dstTheme->composer['extra']['regions']) ? array_keys($dstTheme->composer['extra']['regions']) : [];

        if (empty($newRegions)) {
            return;
        }

        $existingPositions = $this->BlockRegions
            ->find()
            ->where(['theme' => $src])
            ->all();
        foreach ($existingPositions as $position) {
            if (in_array($position->region, $newRegions)) {
                $newPosition = $this->BlockRegions->newEntity([
                    'block_id' => $position->block_id,
                    'theme' => $dstTheme->name,
                    'region' => $position->region,
                    'ordering' => $position->ordering,
                ]);
                $this->BlockRegions->save($newPosition);
            }
        }
    }
392045
public function copy($source, $dest)
    {
        // Simple copy for a file
        if (is_file($source)) {
            if (file_exists($dest) && (!empty($this->options['overwrite']) || fileatime($source) < fileatime($dest))) {
                return true;
            }

            return copy($source, $dest);
        }

        // Make destination directory
        if (!is_dir($dest)) {
            @mkdir($dest, 0777, true);
        }

        // Loop through the folder
        $dir = dir($source);
        while (false !== $entry = $dir->read()) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }

            // Deep copy directories
            if ($dest !== "$source/$entry") {
                $this->copy("$source/$entry", "$dest/$entry");
            }
        }

        // Clean up
        $dir->close();

        return true;
    }
744086
protected function copy($src, $dst, Module $module)
    {
        $dir = opendir($src);
        $author = 'Terrific Composer';
        @mkdir($dst);

        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                if (is_dir($src . '/' . $file) && ($file != 'skin' || $file == 'skin' && $module->getSkins())) {
                    $this->copy($src . '/' . $file, $dst . '/' . $file, $module);
                }
                else if (!is_dir($src . '/' . $file)) {
                    $old = $src . '/' . $file;
                    $new = '';

                    switch ($file) {
                        case 'TerrificModuleDefault.php':
                            $new = $dst . '/TerrificModule' . StringUtils::camelize($module->getName()) . '.php';
                            if(!empty($new) && !file_exists($new)) {
                                copy($old, $new);
                                $this->rewrite($new,
                                    array('Your Name', 'Default', 'SkinName'),
                                    array($author, (StringUtils::camelize($module->getName())), ''));
                            }
                            break;

                        case 'module.less':
                            if($module->getStyle() == 'less') {
                                $new = $dst . '/' . StringUtils::dash($module->getName()) . '.' . $module->getStyle();
                                if(!empty($new) && !file_exists($new)) {
                                    copy($old, $new);
                                    $this->rewrite($new,
                                        array('Your Name', 'default', 'skinname'),
                                        array($author, StringUtils::dash($module->getName()), ''));
                                }
                            }
                            break;

                        case 'module.css':
                            if($module->getStyle() == 'css') {
                                $new = $dst . '/' . StringUtils::dash($module->getName()) . '.' . $module->getStyle();
                                if(!empty($new) && !file_exists($new)) {
                                    copy($old, $new);
                                    $this->rewrite($new,
                                        array('Your Name', 'default', 'skinname'),
                                        array($author, StringUtils::dash($module->getName()), ''));
                                }
                            }
                            break;

                        case 'skin.less':
                            foreach($module->getSkins() as $skin) {
                                if($skin->getStyle() == 'less') {
                                    $new = $dst . '/' . StringUtils::dash($skin->getName()) . '.' . $skin->getStyle();
                                    if(!empty($new) && !file_exists($new)) {
                                        copy($old, $new);
                                        $this->rewrite($new,
                                            array('Your Name', 'default', 'skinname'),
                                            array($author, StringUtils::dash($skin->getModule()), StringUtils::dash($skin->getName())));
                                    }
                                }
                            }
                            break;

                        case 'skin.css':
                            foreach($module->getSkins() as $skin) {
                                if($skin->getStyle() == 'css') {
                                    $new = $dst . '/' . StringUtils::dash($skin->getName()) . '.' . $skin->getStyle();
                                    if(!empty($new) && !file_exists($new)) {
                                        copy($old, $new);
                                        $this->rewrite($new,
                                            array('Your Name', 'default', 'skinname'),
                                            array($author, StringUtils::dash($skin->getModule()), StringUtils::dash($skin->getName())));
                                    }
                                }
                            }
                            break;

                        case 'default.html.twig':
                            foreach($module->getTemplates() as $template) {
                                $new = $dst . '/' . strtolower($template) . '.html.twig';
                                if(!empty($new) && !file_exists($new)) {
                                    copy($old, $new);
                                    $this->rewrite($new,
                                        array('Your Name', 'Default', 'SkinName'),
                                        array($author, StringUtils::camelize($module->getName()), ''));
                                }
                            }
                            break;

                        case 'Tc.Module.Default.js':
                            $new = $dst . '/' . 'Tc.Module.' . StringUtils::camelize($module->getName()) . '.js';
                            if(!empty($new) && !file_exists($new)) {
                                copy($old, $new);
                                $this->rewrite($new,
                                    array('Your Name', 'Default', 'SkinName'),
                                    array($author, StringUtils::camelize($module->getName()), ''));
                            }
                            break;

                        case 'Tc.Module.Default.Skin.js':
                            foreach($module->getSkins() as $skin) {
                                $new = $dst . '/' . 'Tc.Module.' . StringUtils::camelize($skin->getModule()) . '.' . StringUtils::camelize($skin->getName()) . '.js';
                                if(!empty($new) && !file_exists($new)) {
                                    copy($old, $new);
                                    $this->rewrite($new,
                                        array('Your Name', 'Default', 'SkinName'),
                                        array($author, StringUtils::camelize($skin->getModule()), StringUtils::camelize($skin->getName())));
                                }
                            }
                            break;

                        case 'README.md':
                            $new = $dst . '/README.md';
                            if(!empty($new) && !file_exists($new)) {
                                copy($old, $new);
                            }
                            break;

                        default:
                            // copy file
                            $new = $dst . '/' . $file;
                            if(!empty($new) && !file_exists($new)) {
                                copy($old, $new);
                            }
                            break;
                    }
                }
            }
        }
        closedir($dir);
    }
843181
protected static function copyDir($src, $dst, $mode=null) {
		if($mode === null)
			$mode = static::OVERRIDE;

		if(file_exists($dst)) {
			if($mode & static::MERGEDIR) {}
			elseif($mode & static::RENAME)
				$dst = static::getNewFilename($dst);
			elseif($mode & static::OVERRIDE)
				static::delete($dst);
		}

		$r = true;
		$dir = opendir($src);
		static::mkdir($dst);
		while(false !== ($file = readdir($dir))) {
			if(($file != '.') && ($file != '..'))
				$r = $r && static::copy($src.'/'.$file, $dst.'/'.$file, $mode);
		}
		closedir($dir);

		if($r !== false)
			return $dst;
		return false;
	}