src/Nooku/Composer/Installer/NookuComponent.php
protected function _copyDirectory($source, $target)
    {
        $result = false;

        if (!is_dir($target)) {
            $result = mkdir($target, 0755, true);
        }
        else
        {
            // Clear directory
            $iter = new \RecursiveDirectoryIterator($target);
            foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f)
            {
                if ($f->isDir())
                {
                    if (!in_array($f->getFilename(), array('.', '..'))) {
                        rmdir($f->getPathname());
                    }
                } else {
                    unlink($f->getPathname());
                }
            }
        }

        if (is_dir($target))
        {
            $result = true; // needed for empty directories
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($iterator as $f)
            {
                if ($f->isDir()) {
                    $path = $target.'/'.$iterator->getSubPathName();
                    if (!is_dir($path)) {
                        $result = mkdir($path);
                    }
                } else {
                    $result = copy($f, $target.'/'.$iterator->getSubPathName());
                }

                if ($result === false) {
                    break;
                }
            }
        }

        return $result;
    }
protected function _copyDirectory($source, $target)
    {
        $result = false;

        if (!is_dir($target)) {
            $result = mkdir($target, 0755, true);
        }
        else
        {
            // Clear directory
            $iter = new \RecursiveDirectoryIterator($target);
            foreach (new \RecursiveIteratorIterator($iter, \RecursiveIteratorIterator::CHILD_FIRST) as $f)
            {
                if ($f->isDir())
                {
                    if (!in_array($f->getFilename(), array('.', '..'))) {
                        rmdir($f->getPathname());
                    }
                } else {
                    unlink($f->getPathname());
                }
            }
        }

        if (is_dir($target))
        {
            $result = true; // needed for empty directories
            $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST);
            foreach ($iterator as $f)
            {
                if ($f->isDir()) {
                    $path = $target.'/'.$iterator->getSubPathName();
                    if (!is_dir($path)) {
                        $result = mkdir($path);
                    }
                } else {
                    $result = copy($f, $target.'/'.$iterator->getSubPathName());
                }

                if ($result === false) {
                    break;
                }
            }
        }

        return $result;
    }
protected function _copyDirectory ( $ source , $ target ) { $ result = false ; if ( ! is_dir ( $ target ) ) { $ result = mkdir ( $ target , 0755 , true ) ; } else { // Clear directory $ iter = new \ RecursiveDirectoryIterator ( $ target ) ; foreach ( new \ RecursiveIteratorIterator ( $ iter , \ RecursiveIteratorIterator :: CHILD_FIRST ) as $ f ) { if ( $ f -> isDir ( ) ) { if ( ! in_array ( $ f -> getFilename ( ) , array ( '.' , '..' ) ) ) { rmdir ( $ f -> getPathname ( ) ) ; } } else { unlink ( $ f -> getPathname ( ) ) ; } } } if ( is_dir ( $ target ) ) { $ result = true ; // needed for empty directories $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ source ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ f ) { if ( $ f -> isDir ( ) ) { $ path = $ target . '/' . $ iterator -> getSubPathName ( ) ; if ( ! is_dir ( $ path ) ) { $ result = mkdir ( $ path ) ; } } else { $ result = copy ( $ f , $ target . '/' . $ iterator -> getSubPathName ( ) ) ; } if ( $ result === false ) { break ; } } } return $ result ; }
Copy source folder into target. Clears the target folder first.

@param $source
@param $target
@return bool
Copy source folder into target . Clears the target folder first .