concrete/src/File/Service/File.php
public function copyAll($source, $target, $mode = null)
    {
        if (is_dir($source)) {
            if ($mode == null) {
                @mkdir($target, Config::get('concrete.filesystem.permissions.directory'));
                @chmod($target, Config::get('concrete.filesystem.permissions.directory'));
            } else {
                @mkdir($target, $mode);
                @chmod($target, $mode);
            }

            $d = dir($source);
            while (false !== ($entry = $d->read())) {
                if (substr($entry, 0, 1) === '.') {
                    continue;
                }

                $Entry = $source . '/' . $entry;
                if (is_dir($Entry)) {
                    $this->copyAll($Entry, $target . '/' . $entry, $mode);
                    continue;
                }

                copy($Entry, $target . '/' . $entry);
                if ($mode == null) {
                    @chmod($target . '/' . $entry, $this->getCreateFilePermissions($target)->file);
                } else {
                    @chmod($target . '/' . $entry, $mode);
                }
            }

            $d->close();
        } else {
            if ($mode == null) {
                $mode = $this->getCreateFilePermissions(dirname($target))->file;
            }
            copy($source, $target);
            chmod($target, $mode);
        }
    }
public function copyAll($source, $target, $mode = null)
    {
        if (is_dir($source)) {
            if ($mode == null) {
                @mkdir($target, Config::get('concrete.filesystem.permissions.directory'));
                @chmod($target, Config::get('concrete.filesystem.permissions.directory'));
            } else {
                @mkdir($target, $mode);
                @chmod($target, $mode);
            }

            $d = dir($source);
            while (false !== ($entry = $d->read())) {
                if (substr($entry, 0, 1) === '.') {
                    continue;
                }

                $Entry = $source . '/' . $entry;
                if (is_dir($Entry)) {
                    $this->copyAll($Entry, $target . '/' . $entry, $mode);
                    continue;
                }

                copy($Entry, $target . '/' . $entry);
                if ($mode == null) {
                    @chmod($target . '/' . $entry, $this->getCreateFilePermissions($target)->file);
                } else {
                    @chmod($target . '/' . $entry, $mode);
                }
            }

            $d->close();
        } else {
            if ($mode == null) {
                $mode = $this->getCreateFilePermissions(dirname($target))->file;
            }
            copy($source, $target);
            chmod($target, $mode);
        }
    }
public function copyAll ( $ source , $ target , $ mode = null ) { if ( is_dir ( $ source ) ) { if ( $ mode == null ) { @ mkdir ( $ target , Config :: get ( 'concrete.filesystem.permissions.directory' ) ) ; @ chmod ( $ target , Config :: get ( 'concrete.filesystem.permissions.directory' ) ) ; } else { @ mkdir ( $ target , $ mode ) ; @ chmod ( $ target , $ mode ) ; } $ d = dir ( $ source ) ; while ( false !== ( $ entry = $ d -> read ( ) ) ) { if ( substr ( $ entry , 0 , 1 ) === '.' ) { continue ; } $ Entry = $ source . '/' . $ entry ; if ( is_dir ( $ Entry ) ) { $ this -> copyAll ( $ Entry , $ target . '/' . $ entry , $ mode ) ; continue ; } copy ( $ Entry , $ target . '/' . $ entry ) ; if ( $ mode == null ) { @ chmod ( $ target . '/' . $ entry , $ this -> getCreateFilePermissions ( $ target ) -> file ) ; } else { @ chmod ( $ target . '/' . $ entry , $ mode ) ; } } $ d -> close ( ) ; } else { if ( $ mode == null ) { $ mode = $ this -> getCreateFilePermissions ( dirname ( $ target ) ) -> file ; } copy ( $ source , $ target ) ; chmod ( $ target , $ mode ) ; } }
Recursively copies all items in the source directory or file to the target directory.

@param string $source Source dir/file to copy
@param string $target Place to copy the source
@param int    $mode   What to chmod the file to
Recursively copies all items in the source directory or file to the target directory .