module/Core/src/Grid/Core/Model/FileSystem.php
protected function _copy( $path, $to )
    {
        if ( is_file( $to ) )
        {
            return false;
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator( $path,
                RecursiveDirectoryIterator::CURRENT_AS_FILEINFO |
                RecursiveDirectoryIterator::SKIP_DOTS
            ),
            RecursiveIteratorIterator::SELF_FIRST
        );

        $result = is_dir( $to ) ? true : @ mkdir( $to );

        foreach ( $iterator as $info )
        {
            $toPath = $to . '/' . $iterator->getSubPathName();

            switch ( true )
            {
                case $info->isFile():
                    $result = $result && @ copy( $info->getPathname(), $toPath );
                    break;

                case $info->isDir():
                    $result = $result && @ mkdir( $toPath, 0777 );
                    break;
            }
        }

        return $result;
    }
protected function _copy( $path, $to )
    {
        if ( is_file( $to ) )
        {
            return false;
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator( $path,
                RecursiveDirectoryIterator::CURRENT_AS_FILEINFO |
                RecursiveDirectoryIterator::SKIP_DOTS
            ),
            RecursiveIteratorIterator::SELF_FIRST
        );

        $result = is_dir( $to ) ? true : @ mkdir( $to );

        foreach ( $iterator as $info )
        {
            $toPath = $to . '/' . $iterator->getSubPathName();

            switch ( true )
            {
                case $info->isFile():
                    $result = $result && @ copy( $info->getPathname(), $toPath );
                    break;

                case $info->isDir():
                    $result = $result && @ mkdir( $toPath, 0777 );
                    break;
            }
        }

        return $result;
    }
protected function _copy ( $ path , $ to ) { if ( is_file ( $ to ) ) { return false ; } $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: CURRENT_AS_FILEINFO | RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST ) ; $ result = is_dir ( $ to ) ? true : @ mkdir ( $ to ) ; foreach ( $ iterator as $ info ) { $ toPath = $ to . '/' . $ iterator -> getSubPathName ( ) ; switch ( true ) { case $ info -> isFile ( ) : $ result = $ result && @ copy ( $ info -> getPathname ( ) , $ toPath ) ; break ; case $ info -> isDir ( ) : $ result = $ result && @ mkdir ( $ toPath , 0777 ) ; break ; } } return $ result ; }
Copy entire dir

@param string $path
@param string $to
@return bool
Copy entire dir