lib/Util/Filesystem/Directory.php
public function copyChildren($targetDir)
    {
        $info = new \SplFileInfo($targetDir);

        if (!$info->isDir())
        {
            throw new InvalidArgumentException(sprintf('Target dir not found'));
        }

        if (!$info->isReadable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not readable'));
        }

        if (!$info->isWritable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not writable'));
        }

        $files = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        foreach($files as $info)
        {
            $sourcePathname = $info->getPathname();
            $subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
            $targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);

            if ($info->isDir())
            {
                mkdir($targetPathname);
            }
            else {
                copy($sourcePathname, $targetPathname);
            }
        }
    }
public function copyChildren($targetDir)
    {
        $info = new \SplFileInfo($targetDir);

        if (!$info->isDir())
        {
            throw new InvalidArgumentException(sprintf('Target dir not found'));
        }

        if (!$info->isReadable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not readable'));
        }

        if (!$info->isWritable())
        {
            throw new InvalidArgumentException(sprintf('Target dir not writable'));
        }

        $files = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($this->dir, \FilesystemIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST
        );

        foreach($files as $info)
        {
            $sourcePathname = $info->getPathname();
            $subdirPathname = $this->subtractBasedir($sourcePathname, $this->dir);
            $targetPathname = sprintf('%s/%s', $targetDir, $subdirPathname);

            if ($info->isDir())
            {
                mkdir($targetPathname);
            }
            else {
                copy($sourcePathname, $targetPathname);
            }
        }
    }
public function copyChildren ( $ targetDir ) { $ info = new \ SplFileInfo ( $ targetDir ) ; if ( ! $ info -> isDir ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not found' ) ) ; } if ( ! $ info -> isReadable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not readable' ) ) ; } if ( ! $ info -> isWritable ( ) ) { throw new InvalidArgumentException ( sprintf ( 'Target dir not writable' ) ) ; } $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ this -> dir , \ FilesystemIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ files as $ info ) { $ sourcePathname = $ info -> getPathname ( ) ; $ subdirPathname = $ this -> subtractBasedir ( $ sourcePathname , $ this -> dir ) ; $ targetPathname = sprintf ( '%s/%s' , $ targetDir , $ subdirPathname ) ; if ( $ info -> isDir ( ) ) { mkdir ( $ targetPathname ) ; } else { copy ( $ sourcePathname , $ targetPathname ) ; } } }
Copy the children of this directory into targetDir

@param string $targetDir Target directory pathname

@return void
Copy the children of this directory into targetDir