Example #1
0
 /**
  * Copy a file, takes care of symbolic links
  *
  * @param File $src Source path and name file to copy.
  * @param File $dest Destination path and name of new file.
  *
  * @return void     
  * @throws Exception if file cannot be copied.
  */
 public function copy(File $src, File $dest)
 {
     global $php_errormsg;
     if (!$src->isLink()) {
         return parent::copy($src, $dest);
     }
     $srcPath = $src->getAbsolutePath()->toNative();
     $destPath = $dest->getAbsolutePath()->toNative();
     $linkTarget = $src->getLinkTarget();
     if (false === @symlink($linkTarget, $destPath)) {
         $msg = "FileSystem::copy() FAILED. Cannot create symlink from {$destPath} to {$linkTarget}.";
         throw new Exception($msg);
     }
 }