src/FS/Folder/Editor.php
public static function copyFolder( $sourceFolder, $targetFolder, $force = FALSE, $skipDotEntries = TRUE )
	{
		if( !self::isFolder( $sourceFolder ) )												//  Source Folder not existing
			throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be copied because it is not existing' );

		$count			= 0;																//  initialize Object Counter
		$sourceFolder	= self::correctPath( $sourceFolder );								//  add Slash to Source Folder
		$targetFolder	= self::correctPath( $targetFolder );								//  add Slash to Target Folder
		if( self::isFolder( $targetFolder ) && !$force )									//  Target Folder is existing, not forced
			throw new RuntimeException( 'Folder "'.$targetFolder.'" is already existing. See Option "force"' );
		else if( !self::isFolder( $targetFolder ) )											//  Target Folder is not existing
			$count	+= (int) self::createFolder( $targetFolder );							//  create TargetFolder and count

		$index	= new FS_Folder_Iterator( $sourceFolder, TRUE, TRUE, $skipDotEntries );		//  Index of Source Folder
		foreach( $index as $entry )
		{
			if( $entry->isDot() )															//  Dot Folders
				continue;																	//  skip them
			if( $entry->isDir() )															//  nested Folder
			{
				$source	= $entry->getPathname();											//  Source Folder Name
				$target	= $targetFolder.$entry->getFilename()."/";							//  Target Folder Name
				$count	+= self::copyFolder( $source, $target, $force, $skipDotEntries );	//  copy Folder recursive and count
			}
			else if( $entry->isFile() )														//  nested File
			{
				$targetFile	= $targetFolder.$entry->getFilename();
				if( file_exists( $targetFile ) && !$force )
					throw new RuntimeException( 'File "'.$targetFile.'" is already existing. See Option "force"' );
				$count	+= (int) copy( $entry->getPathname(), $targetFile );				//  copy File and count
			}
		}
		return $count;																		//  return Object Count
	}
public static function copyFolder( $sourceFolder, $targetFolder, $force = FALSE, $skipDotEntries = TRUE )
	{
		if( !self::isFolder( $sourceFolder ) )												//  Source Folder not existing
			throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be copied because it is not existing' );

		$count			= 0;																//  initialize Object Counter
		$sourceFolder	= self::correctPath( $sourceFolder );								//  add Slash to Source Folder
		$targetFolder	= self::correctPath( $targetFolder );								//  add Slash to Target Folder
		if( self::isFolder( $targetFolder ) && !$force )									//  Target Folder is existing, not forced
			throw new RuntimeException( 'Folder "'.$targetFolder.'" is already existing. See Option "force"' );
		else if( !self::isFolder( $targetFolder ) )											//  Target Folder is not existing
			$count	+= (int) self::createFolder( $targetFolder );							//  create TargetFolder and count

		$index	= new FS_Folder_Iterator( $sourceFolder, TRUE, TRUE, $skipDotEntries );		//  Index of Source Folder
		foreach( $index as $entry )
		{
			if( $entry->isDot() )															//  Dot Folders
				continue;																	//  skip them
			if( $entry->isDir() )															//  nested Folder
			{
				$source	= $entry->getPathname();											//  Source Folder Name
				$target	= $targetFolder.$entry->getFilename()."/";							//  Target Folder Name
				$count	+= self::copyFolder( $source, $target, $force, $skipDotEntries );	//  copy Folder recursive and count
			}
			else if( $entry->isFile() )														//  nested File
			{
				$targetFile	= $targetFolder.$entry->getFilename();
				if( file_exists( $targetFile ) && !$force )
					throw new RuntimeException( 'File "'.$targetFile.'" is already existing. See Option "force"' );
				$count	+= (int) copy( $entry->getPathname(), $targetFile );				//  copy File and count
			}
		}
		return $count;																		//  return Object Count
	}
public static function copyFolder ( $ sourceFolder , $ targetFolder , $ force = FALSE , $ skipDotEntries = TRUE ) { if ( ! self :: isFolder ( $ sourceFolder ) ) //  Source Folder not existing throw new RuntimeException ( 'Folder "' . $ sourceFolder . '" cannot be copied because it is not existing' ) ; $ count = 0 ; //  initialize Object Counter $ sourceFolder = self :: correctPath ( $ sourceFolder ) ; //  add Slash to Source Folder $ targetFolder = self :: correctPath ( $ targetFolder ) ; //  add Slash to Target Folder if ( self :: isFolder ( $ targetFolder ) && ! $ force ) //  Target Folder is existing, not forced throw new RuntimeException ( 'Folder "' . $ targetFolder . '" is already existing. See Option "force"' ) ; else if ( ! self :: isFolder ( $ targetFolder ) ) //  Target Folder is not existing $ count += ( int ) self :: createFolder ( $ targetFolder ) ; //  create TargetFolder and count $ index = new FS_Folder_Iterator ( $ sourceFolder , TRUE , TRUE , $ skipDotEntries ) ; //  Index of Source Folder foreach ( $ index as $ entry ) { if ( $ entry -> isDot ( ) ) //  Dot Folders continue ; //  skip them if ( $ entry -> isDir ( ) ) //  nested Folder { $ source = $ entry -> getPathname ( ) ; //  Source Folder Name $ target = $ targetFolder . $ entry -> getFilename ( ) . "/" ; //  Target Folder Name $ count += self :: copyFolder ( $ source , $ target , $ force , $ skipDotEntries ) ; //  copy Folder recursive and count } else if ( $ entry -> isFile ( ) ) //  nested File { $ targetFile = $ targetFolder . $ entry -> getFilename ( ) ; if ( file_exists ( $ targetFile ) && ! $ force ) throw new RuntimeException ( 'File "' . $ targetFile . '" is already existing. See Option "force"' ) ; $ count += ( int ) copy ( $ entry -> getPathname ( ) , $ targetFile ) ; //  copy File and count } } return $ count ; //  return Object Count }
Copies a Folder recursive to another Path and returns Number of copied Files and Folders.
@access		public
@static
@param		string		$sourceFolder	Folder Name of Folder to copy
@param		string		$targetFolder	Folder Name to Target Folder
@param		bool		$force			Flag: force Copy if file is existing
@param		bool		$skipDotEntries	Flag: skip Files and Folders starting with Dot
@return		int
Copies a Folder recursive to another Path and returns Number of copied Files and Folders .