Append the src[key] array to the dest array, if key is present
@param array $src
@param string $key
@param array $dest
@return array
176448
private static function appendIfPresent($src, $key, $dest)
    {
        if (!empty($src[$key])) {
            return array_merge($dest, $src[$key]);
        } else {
            return $dest;
        }
    }
629690
public Sftp get(String src, String dest) {
		try {
			channel.get(src, dest);
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		return this;
	}
63859
public static function copy($src, $dest, $force = false)
    {
        @set_time_limit((int) ini_get('max_execution_time'));

        // Eliminate trailing directory separators, if any
        $src = rtrim($src, '/\\');
        $dest = rtrim($dest, '/\\');

        if (!is_dir($src)) {
            throw new FilesystemException('Source folder not found', -1);
        }

        if (is_dir($dest) && !$force) {
            throw new FilesystemException('Destination folder exists', -1);
        }

        // Make sure the destination exists
        if (!static::create($dest)) {
            throw new FilesystemException('Cannot create destination folder', -1);
        }

        $sources = static::items($src, true, static::PATH_RELATIVE);

        // Walk through the directory copying files and recursing into folders.
        foreach ($sources as $file) {
            $srcFile = $src . '/' . $file;
            $destFile = $dest . '/' . $file;

            if (is_dir($srcFile)) {
                static::create($destFile);
            } elseif (is_file($srcFile)) {
                File::copy($srcFile, $destFile, $force);
            }
        }

        return true;
    }
375749
function extend($key,$src,$keep=FALSE) {
		$ref=&$this->ref($key);
		if (!$ref)
			$ref=[];
		$out=array_replace_recursive(
			is_string($src)?$this->hive[$src]:$src,$ref);
		if ($keep)
			$ref=$out;
		return $out;
	}
1167111
public static function copyDir($src, $dst)
    {
        if (is_link($src)) {
            symlink(readlink($src), $dst);
        } elseif (is_dir($src)) {
            if (is_dir($dst) === false) {
                mkdir($dst, 0775, true);
            }
            // copy files recursive
            foreach (scandir($src) as $file) {
                if ($file != '.' && $file != '..') {
                    FileSystem::copyDir("$src/$file", "$dst/$file");
                }
            }

        } elseif (is_file($src)) {
            copy($src, $dst);
        } else {
            // do nothing, we didn't have a directory to copy
        }
    }
38539
protected static function copyRecursive( $src, $dest )
	{
		self::createDirectory( $dest );

		$iterator = new \RecursiveIteratorIterator(
			new \RecursiveDirectoryIterator( $src, \RecursiveDirectoryIterator::SKIP_DOTS ),
			\RecursiveIteratorIterator::SELF_FIRST
		);

		foreach( $iterator as $item )
		{
			$target = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();

			if( $item->isDir() === false )
			{
				if( copy( $item, $target ) === false ) {
					throw new \RuntimeException( sprintf( 'Unable to copy file "%1$s"', $item ) );
				}
			}
			else
			{
				self::createDirectory( $target );
			}
		}
	}
672234
public function copyr($source, $dest)
    {
        // Simple copy for a file
        if (is_file($source)) {
            return $this->copy($source, $dest);
        }
        // Make destination directory
        if (!is_dir($dest)) {
            $this->mkdir($dest);
        }
        // Loop through the folder
        $dir = $this->dir($source);
        while ( false !== ($entry = $dir->read()) ) {
            // Skip pointers
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            if (!$this->copyable($entry)) {
                continue;
            }
            // Deep copy directories
            if ($dest !== "$source/$entry") {
                $this->copyr("$source/$entry", "$dest/$entry");
            }
        }
        // Clean up
        $dir->close();
        return true;
    }
775685
public function rsyncCommand($src, $dest, array $rsyncOptions)
    {
        if (strpos($src, ':') !== false) {
            $site_env_id = $this->getSiteEnvIdFromPath($src);
            $src = $this->removeSiteEnvIdFromPath($src);
        } else {
            $site_env_id = $this->getSiteEnvIdFromPath($dest);
            $dest = $this->removeSiteEnvIdFromPath($dest);
        }

        return $this->rsync($site_env_id, $src, $dest, $rsyncOptions);
    }
510716
public static function CopyFiles($source,$dest){
        File::mkfolders($dest);
        $folder = opendir($source);
        while($file = readdir($folder)){
            if ($file == '.' || $file == '..') continue;

            if(is_dir($source.'/'.$file)){
                mkdir($dest.'/'.$file,0777);
                $this->CopyFiles($source.'/'.$file,$dest.'/'.$file);
            }else copy($source.'/'.$file,$dest.'/'.$file);
        }
        closedir($folder);
        return 1;
    }
1300440
public function addItem($src, $thumbnail=''){
        if(!$src) {
            return $this; 
        }

        if(!$this->data['list']) {
            $this->data['list'] = [];
        }

        $item = [];
        $item['src'] = $src;
        if($thumbnail) {
            $item['thumbnail'] = $thumbnail;
        }

        $this->data['list'][] = $item;
        return $this;
    }
605074
public static function script($src, array $attrs = [])
    {
        $attrs = array_merge([
            'src' => $src
        ], $attrs);

        return static::tag('script', null, $attrs);
    }
1367385
public static BufferedImage copy(BufferedImage src, BufferedImage dest) {
        dest.getGraphics().drawImage(src, 0, 0, null);
        return dest;
    }
424689
public function fit($src, $dest, $width, $height){
        // Calculate
        $size = getimagesize($src);
        $ratio = max($width / $size[0], $height / $size[1]);
        $old_width = $size[0];
        $old_height = $size[1];
        $new_width = intval($old_width * $ratio);
        $new_height = intval($old_height * $ratio);
        // Resize
        @ini_set( 'memory_limit', apply_filters( 'image_memory_limit', WP_MAX_MEMORY_LIMIT ) );
        $image = imagecreatefromstring( file_get_contents( $src ) );
        $new_image = wp_imagecreatetruecolor( $new_width, $new_height );
        imagecopyresampled( $new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $old_width, $old_height);
        if ( IMAGETYPE_PNG == $size[2] && function_exists('imageistruecolor') && !imageistruecolor( $image ) ){
            imagetruecolortopalette( $new_image, false, imagecolorstotal( $image ) );
        }
        // Destroy old image
        imagedestroy( $image );
        // Save
        switch($size[2]){
            case IMAGETYPE_GIF:
                $result = imagegif($new_image, $dest);
                break;
            case IMAGETYPE_PNG:
                $result = imagepng($new_image, $dest);
                break;
            default:
                $result = imagejpeg($new_image, $dest);
                break;
        }
        imagedestroy($new_image);
        return $result;
    }
561715
function merge($key,$src,$keep=FALSE) {
		$ref=&$this->ref($key);
		if (!$ref)
			$ref=[];
		$out=array_merge($ref,is_string($src)?$this->hive[$src]:$src);
		if ($keep)
			$ref=$out;
		return $out;
	}
936674
private function __copyDir($src, $dst, &$files = null)
    {
        $dir = opendir($src);
        @mkdir($dst);
        while (false !== ($file = readdir($dir))) {
            if (('.' != $file) && ('..' != $file)) {
                if (is_dir($src.'/'.$file)) {
                    $this->__copyDir($src.'/'.$file, $dst.'/'.$file, $files);
                } else {
                    copy($src.'/'.$file, $dst.'/'.$file);
                    if (\is_array($files)) {
                        $files[] = $dst.'/'.$file;
                    }
                }
            }
        }
        closedir($dir);
    }
186807
public function build($src, $dest, Theme $theme)
    {
        $this->filesystem->purge($dest);

        foreach ($theme->getCopyFiles() as $from => $to) {
            $this->filesystem->copy($from, $dest . '/' . $to);
        }

        $treeItems = $this->parse(new SplFileInfo($src), $dest);
        $theme->setTreeItems($treeItems);

        //build all doc pages
        foreach ($treeItems as $item) {
            $this->exportFile($item, $theme);
        }

        //build index page
        if (!$this->filesystem->exists($dest . '/index.html')) {
            $theme->setCurrentItem('index', '');
            $html = $this->renderTemplate($theme);
            $this->filesystem->writeFile($dest . '/index.html', $html);
        }
    }
593259
public function addCover($src, $dest = '', $id = 'cover'){
		if( file_exists($src) ){
			if( !$dest ){
				$dest = 'Image'.DIRECTORY_SEPARATOR.basename($src);
			}
			$this->distributor->copy($src, 'OEBPS'.DIRECTORY_SEPARATOR.$dest);
			$this->opf->addItem($dest, $id, ['cover-image']);
			$this->opf->addMeta('meta', '', [
				'name' => 'cover',
				'content' => $id
			]);
		}
	}