src/xPDO/Cache/xPDOCacheManager.php
public function copyFile($source, $target, $options = array()) {
        $copied= false;
        if (!is_array($options)) $options = is_scalar($options) && !is_bool($options) ? array('new_file_permissions' => $options) : array();
        if (func_num_args() === 4) $options['new_folder_permissions'] = func_get_arg(3);
        if ($this->writeTree(dirname($target), $options)) {
            $existed= file_exists($target);
            if ($existed && $this->getOption('copy_newer_only', $options, false) && (($ttime = filemtime($target)) > ($stime = filemtime($source)))) {
                $this->xpdo->log(xPDO::LOG_LEVEL_INFO, "xPDOCacheManager->copyFile(): Skipping copy of newer file {$target} ({$ttime}) from {$source} ({$stime})");
            } else {
                $copied= copy($source, $target);
            }
            if ($copied) {
                if (!$this->getOption('copy_preserve_permissions', $options, false)) {
                    $fileMode = $this->getOption('new_file_permissions', $options, $this->getFilePermissions());
                    if (is_string($fileMode)) $fileMode = octdec($fileMode);
                    @ chmod($target, $fileMode);
                }
                if ($this->getOption('copy_preserve_filemtime', $options, true)) @ touch($target, filemtime($source));
                if ($this->getOption('copy_return_file_stat', $options, false)) {
                    $stat = stat($target);
                    if (is_array($stat)) {
                        $stat['overwritten']= $existed;
                        $copied = array($target => $stat);
                    }
                }
            }
        }
        if (!$copied) {
            $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "xPDOCacheManager->copyFile(): Could not copy file {$source} to {$target}");
        }
        return $copied;
    }
public function copyFile($source, $target, $options = array()) {
        $copied= false;
        if (!is_array($options)) $options = is_scalar($options) && !is_bool($options) ? array('new_file_permissions' => $options) : array();
        if (func_num_args() === 4) $options['new_folder_permissions'] = func_get_arg(3);
        if ($this->writeTree(dirname($target), $options)) {
            $existed= file_exists($target);
            if ($existed && $this->getOption('copy_newer_only', $options, false) && (($ttime = filemtime($target)) > ($stime = filemtime($source)))) {
                $this->xpdo->log(xPDO::LOG_LEVEL_INFO, "xPDOCacheManager->copyFile(): Skipping copy of newer file {$target} ({$ttime}) from {$source} ({$stime})");
            } else {
                $copied= copy($source, $target);
            }
            if ($copied) {
                if (!$this->getOption('copy_preserve_permissions', $options, false)) {
                    $fileMode = $this->getOption('new_file_permissions', $options, $this->getFilePermissions());
                    if (is_string($fileMode)) $fileMode = octdec($fileMode);
                    @ chmod($target, $fileMode);
                }
                if ($this->getOption('copy_preserve_filemtime', $options, true)) @ touch($target, filemtime($source));
                if ($this->getOption('copy_return_file_stat', $options, false)) {
                    $stat = stat($target);
                    if (is_array($stat)) {
                        $stat['overwritten']= $existed;
                        $copied = array($target => $stat);
                    }
                }
            }
        }
        if (!$copied) {
            $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "xPDOCacheManager->copyFile(): Could not copy file {$source} to {$target}");
        }
        return $copied;
    }
public function copyFile ( $ source , $ target , $ options = array ( ) ) { $ copied = false ; if ( ! is_array ( $ options ) ) $ options = is_scalar ( $ options ) && ! is_bool ( $ options ) ? array ( 'new_file_permissions' => $ options ) : array ( ) ; if ( func_num_args ( ) === 4 ) $ options [ 'new_folder_permissions' ] = func_get_arg ( 3 ) ; if ( $ this -> writeTree ( dirname ( $ target ) , $ options ) ) { $ existed = file_exists ( $ target ) ; if ( $ existed && $ this -> getOption ( 'copy_newer_only' , $ options , false ) && ( ( $ ttime = filemtime ( $ target ) ) > ( $ stime = filemtime ( $ source ) ) ) ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_INFO , "xPDOCacheManager->copyFile(): Skipping copy of newer file {$target} ({$ttime}) from {$source} ({$stime})" ) ; } else { $ copied = copy ( $ source , $ target ) ; } if ( $ copied ) { if ( ! $ this -> getOption ( 'copy_preserve_permissions' , $ options , false ) ) { $ fileMode = $ this -> getOption ( 'new_file_permissions' , $ options , $ this -> getFilePermissions ( ) ) ; if ( is_string ( $ fileMode ) ) $ fileMode = octdec ( $ fileMode ) ; @ chmod ( $ target , $ fileMode ) ; } if ( $ this -> getOption ( 'copy_preserve_filemtime' , $ options , true ) ) @ touch ( $ target , filemtime ( $ source ) ) ; if ( $ this -> getOption ( 'copy_return_file_stat' , $ options , false ) ) { $ stat = stat ( $ target ) ; if ( is_array ( $ stat ) ) { $ stat [ 'overwritten' ] = $ existed ; $ copied = array ( $ target => $ stat ) ; } } } } if ( ! $ copied ) { $ this -> xpdo -> log ( xPDO :: LOG_LEVEL_ERROR , "xPDOCacheManager->copyFile(): Could not copy file {$source} to {$target}" ) ; } return $ copied ; }
Copies a file from a source file to a target directory.

@access public
@param string $source The absolute path of the source file.
@param string $target The absolute path of the target destination
directory.
@param array $options An array of options for this function.
@return boolean|array Returns true if the copy operation was successful, or a single element
array with filename as key and stat results of the successfully copied file as a result.
Copies a file from a source file to a target directory .