protected function _folder($oldPath, $newPath) {
        if (!is_dir($newPath)) {
            $oldumask = umask(0);
            mkdir($newPath, 01777); // so you get the sticky bit set 
            umask($oldumask);
        } elseif (filemtime($oldPath) < filemtime($newPath)) {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' < ' . filemtime($newPath));
            return;
        } else {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' > ' . filemtime($newPath));
        }
        $dir = @opendir($oldPath) or trigger_error("Unable to open original folder to copy it! ($oldPath)");
        while ($file = readdir($dir)) {
            if ($file != "." && $file != ".." && !is_dir("$oldPath/$file")) {
                copy("$oldPath/$file", "$newPath/$file");
            } elseif ($file != "." && $file != "..") {
                $this->_folder("$oldPath/$file", "$newPath/$file");
            }
        }
        closedir($dir);
    }
protected function _folder($oldPath, $newPath) {
        if (!is_dir($newPath)) {
            $oldumask = umask(0);
            mkdir($newPath, 01777); // so you get the sticky bit set 
            umask($oldumask);
        } elseif (filemtime($oldPath) < filemtime($newPath)) {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' < ' . filemtime($newPath));
            return;
        } else {
            //$this->debug($oldPath . ': ' . filemtime($oldPath). ' > ' . filemtime($newPath));
        }
        $dir = @opendir($oldPath) or trigger_error("Unable to open original folder to copy it! ($oldPath)");
        while ($file = readdir($dir)) {
            if ($file != "." && $file != ".." && !is_dir("$oldPath/$file")) {
                copy("$oldPath/$file", "$newPath/$file");
            } elseif ($file != "." && $file != "..") {
                $this->_folder("$oldPath/$file", "$newPath/$file");
            }
        }
        closedir($dir);
    }
protected function _folder ( $ oldPath , $ newPath ) { if ( ! is_dir ( $ newPath ) ) { $ oldumask = umask ( 0 ) ; mkdir ( $ newPath , 01777 ) ; // so you get the sticky bit set  umask ( $ oldumask ) ; } elseif ( filemtime ( $ oldPath ) < filemtime ( $ newPath ) ) { //$this->debug($oldPath . ': ' . filemtime($oldPath). ' < ' . filemtime($newPath)); return ; } else { //$this->debug($oldPath . ': ' . filemtime($oldPath). ' > ' . filemtime($newPath)); } $ dir = @ opendir ( $ oldPath ) or trigger_error ( "Unable to open original folder to copy it! ($oldPath)" ) ; while ( $ file = readdir ( $ dir ) ) { if ( $ file != "." && $ file != ".." && ! is_dir ( "$oldPath/$file" ) ) { copy ( "$oldPath/$file" , "$newPath/$file" ) ; } elseif ( $ file != "." && $ file != ".." ) { $ this -> _folder ( "$oldPath/$file" , "$newPath/$file" ) ; } } closedir ( $ dir ) ; }
Copy folder contents from one location to another
@param string $oldPath
@param string $newPath
Copy folder contents from one location to another