/**
  * Previously in t3lib_extFileFunc::func_copy()
  * copies a source file (from any location) in to the target
  * folder, the latter has to be part of this storage
  *
  * @param 	\TYPO3\CMS\Core\Resource\FileInterface	$file
  * @param 	\TYPO3\CMS\Core\Resource\Folder $targetFolder
  * @param 	string	$conflictMode	"overrideExistingFile", "renameNewFile", "cancel
  * @param 	string	$targetFileName	an optional destination fileName
  * @return \TYPO3\CMS\Core\Resource\FileInterface
  */
 public function copyFile(\TYPO3\CMS\Core\Resource\FileInterface $file, \TYPO3\CMS\Core\Resource\Folder $targetFolder, $targetFileName = NULL, $conflictMode = 'renameNewFile')
 {
     $this->emitPreFileCopySignal($file, $targetFolder);
     $this->checkFileCopyPermissions($file, $targetFolder, $targetFileName);
     if ($targetFileName === NULL) {
         $targetFileName = $file->getName();
     }
     // File exists and we should abort, let's abort
     if ($conflictMode === 'cancel' && $targetFolder->hasFile($targetFileName)) {
         throw new \TYPO3\CMS\Core\Resource\Exception\ExistingTargetFileNameException('The target file already exists.', 1320291063);
     }
     // File exists and we should find another name, let's find another one
     if ($conflictMode === 'renameNewFile' && $targetFolder->hasFile($targetFileName)) {
         $targetFileName = $this->getUniqueName($targetFolder, $targetFileName);
     }
     $sourceStorage = $file->getStorage();
     // Call driver method to create a new file from an existing file object,
     // and return the new file object
     try {
         if ($sourceStorage == $this) {
             $newFileObject = $this->driver->copyFileWithinStorage($file, $targetFolder, $targetFileName);
         } else {
             $tempPath = $file->getForLocalProcessing();
             $newFileObject = $this->driver->addFile($tempPath, $targetFolder, $targetFileName);
         }
     } catch (\TYPO3\CMS\Core\Resource\Exception\AbstractFileOperationException $e) {
         throw $e;
     }
     $this->emitPostFileCopySignal($file, $targetFolder);
     return $newFileObject;
 }