src/core/framework/core/3rdparty/ezcomponents/Base/src/file.php
static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 )
    {
        // Check if source file exists at all.
        if ( !is_file( $source ) && !is_dir( $source ) )
        {
            throw new ezcBaseFileNotFoundException( $source );
        }

        // Destination file should NOT exist
        if ( is_file( $destination ) || is_dir( $destination ) )
        {
            throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE );
        }

        // Skip non readable files in source directory
        if ( !is_readable( $source ) )
        {
            return;
        }

        // Copy
        if ( is_dir( $source ) )
        {
            mkdir( $destination );
            // To ignore umask, umask() should not be changed with
            // multithreaded servers...
            chmod( $destination, $dirMode );
        }
        elseif ( is_file( $source ) )
        {
            copy( $source, $destination );
            chmod( $destination, $fileMode );
        }

        if ( ( $depth === 0 ) ||
            ( !is_dir( $source ) ) )
        {
            // Do not recurse (any more)
            return;
        }

        // Recurse
        $dh = opendir( $source );
        while ( ( $file = readdir( $dh ) ) !== false )
        {
            if ( ( $file === '.' ) ||
                ( $file === '..' ) )
            {
                continue;
            }

            self::copyRecursive(
                $source . '/' . $file,
                $destination . '/' . $file,
                $depth - 1, $dirMode, $fileMode
            );
        }
    }
static public function copyRecursive( $source, $destination, $depth = -1, $dirMode = 0775, $fileMode = 0664 )
    {
        // Check if source file exists at all.
        if ( !is_file( $source ) && !is_dir( $source ) )
        {
            throw new ezcBaseFileNotFoundException( $source );
        }

        // Destination file should NOT exist
        if ( is_file( $destination ) || is_dir( $destination ) )
        {
            throw new ezcBaseFilePermissionException( $destination, ezcBaseFileException::WRITE );
        }

        // Skip non readable files in source directory
        if ( !is_readable( $source ) )
        {
            return;
        }

        // Copy
        if ( is_dir( $source ) )
        {
            mkdir( $destination );
            // To ignore umask, umask() should not be changed with
            // multithreaded servers...
            chmod( $destination, $dirMode );
        }
        elseif ( is_file( $source ) )
        {
            copy( $source, $destination );
            chmod( $destination, $fileMode );
        }

        if ( ( $depth === 0 ) ||
            ( !is_dir( $source ) ) )
        {
            // Do not recurse (any more)
            return;
        }

        // Recurse
        $dh = opendir( $source );
        while ( ( $file = readdir( $dh ) ) !== false )
        {
            if ( ( $file === '.' ) ||
                ( $file === '..' ) )
            {
                continue;
            }

            self::copyRecursive(
                $source . '/' . $file,
                $destination . '/' . $file,
                $depth - 1, $dirMode, $fileMode
            );
        }
    }
static public function copyRecursive ( $ source , $ destination , $ depth = - 1 , $ dirMode = 0775 , $ fileMode = 0664 ) { // Check if source file exists at all. if ( ! is_file ( $ source ) && ! is_dir ( $ source ) ) { throw new ezcBaseFileNotFoundException ( $ source ) ; } // Destination file should NOT exist if ( is_file ( $ destination ) || is_dir ( $ destination ) ) { throw new ezcBaseFilePermissionException ( $ destination , ezcBaseFileException :: WRITE ) ; } // Skip non readable files in source directory if ( ! is_readable ( $ source ) ) { return ; } // Copy if ( is_dir ( $ source ) ) { mkdir ( $ destination ) ; // To ignore umask, umask() should not be changed with // multithreaded servers... chmod ( $ destination , $ dirMode ) ; } elseif ( is_file ( $ source ) ) { copy ( $ source , $ destination ) ; chmod ( $ destination , $ fileMode ) ; } if ( ( $ depth === 0 ) || ( ! is_dir ( $ source ) ) ) { // Do not recurse (any more) return ; } // Recurse $ dh = opendir ( $ source ) ; while ( ( $ file = readdir ( $ dh ) ) !== false ) { if ( ( $ file === '.' ) || ( $ file === '..' ) ) { continue ; } self :: copyRecursive ( $ source . '/' . $ file , $ destination . '/' . $ file , $ depth - 1 , $ dirMode , $ fileMode ) ; } }
Recursively copy a file or directory.

Recursively copy a file or directory in $source to the given
destination. If a depth is given, the operation will stop, if the given
recursion depth is reached. A depth of -1 means no limit, while a depth
of 0 means, that only the current file or directory will be copied,
without any recursion.

You may optionally define modes used to create files and directories.

@throws ezcBaseFileNotFoundException
If the $sourceDir directory is not a directory or does not exist.
@throws ezcBaseFilePermissionException
If the $sourceDir directory could not be opened for reading, or the
destination is not writeable.

@param string $source
@param string $destination
@param int $depth
@param int $dirMode
@param int $fileMode
@return void
Recursively copy a file or directory .