Driver/LocalDriver.php
private function copyDir(Response $response, $target, $dst, $newFolder = '')
    {
        $folder = trim(strrchr($target, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
        $newFolder = $newFolder ?: $dst.DIRECTORY_SEPARATOR.$folder;
        if (file_exists($newFolder)) {
            throw new ExistsException(sprintf('folder "%s" exists', $newFolder));
        }
        mkdir($newFolder);
        $response->addAdded($this->getFileInfo($newFolder));
        foreach (glob($target.'/*') as $name) {
            if (is_dir($name)) {
                $this->copyDir($response, $name, $newFolder);
            } else {
                $filename = $newFolder.DIRECTORY_SEPARATOR.$this->basename($name);
                copy($name, $filename);
                $response->addAdded($this->getFileInfo($filename));
            }
        }
    }
private function copyDir(Response $response, $target, $dst, $newFolder = '')
    {
        $folder = trim(strrchr($target, DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR);
        $newFolder = $newFolder ?: $dst.DIRECTORY_SEPARATOR.$folder;
        if (file_exists($newFolder)) {
            throw new ExistsException(sprintf('folder "%s" exists', $newFolder));
        }
        mkdir($newFolder);
        $response->addAdded($this->getFileInfo($newFolder));
        foreach (glob($target.'/*') as $name) {
            if (is_dir($name)) {
                $this->copyDir($response, $name, $newFolder);
            } else {
                $filename = $newFolder.DIRECTORY_SEPARATOR.$this->basename($name);
                copy($name, $filename);
                $response->addAdded($this->getFileInfo($filename));
            }
        }
    }
private function copyDir ( Response $ response , $ target , $ dst , $ newFolder = '' ) { $ folder = trim ( strrchr ( $ target , DIRECTORY_SEPARATOR ) , DIRECTORY_SEPARATOR ) ; $ newFolder = $ newFolder ? : $ dst . DIRECTORY_SEPARATOR . $ folder ; if ( file_exists ( $ newFolder ) ) { throw new ExistsException ( sprintf ( 'folder "%s" exists' , $ newFolder ) ) ; } mkdir ( $ newFolder ) ; $ response -> addAdded ( $ this -> getFileInfo ( $ newFolder ) ) ; foreach ( glob ( $ target . '/*' ) as $ name ) { if ( is_dir ( $ name ) ) { $ this -> copyDir ( $ response , $ name , $ newFolder ) ; } else { $ filename = $ newFolder . DIRECTORY_SEPARATOR . $ this -> basename ( $ name ) ; copy ( $ name , $ filename ) ; $ response -> addAdded ( $ this -> getFileInfo ( $ filename ) ) ; } } }
copy dir and all inside.

@param Response $response
@param string   $target
@param string   $dst
@param string   $newFolder
copy dir and all inside .