copy this file to an other place

@param File $to other place

@return File
435814
public function copy(File $to): File {
		$this->manager->copy(
			$this->getUrl(),
			$path = Paths::normalize(Paths::appendPath($to->getUrl(), $this->getName()))
		);

		return new File($path);
	}
738520
public function copy(string $newFilePath, bool $overwrite = true): self
    {
        $newFilePath = normalize_path($newFilePath);

        if ($overwrite || !is_file($newFilePath)) {
            if (copy($this->path, $newFilePath)) {
                return new self($newFilePath);
            }
            throw new FileException('Cannot copy file to the new file path ('.$newFilePath.') for unknown reasons');
        }
        throw new FileException('Cannot copy file, because the new file path ('.$newFilePath.') already exists', FileException::ALREADY_EXIST);
    }
914322
public static int copyFile(String from, String to) {
		InputStream inStream = null;
		FileOutputStream fs = null;
		try {
			int bytesum = 0;
			int byteread;
			File oldfile = new File(from);
			if (oldfile.exists()) {
				inStream = new FileInputStream(from);
				fs = new FileOutputStream(to);
				byte[] buffer = new byte[1444];
				while ((byteread = inStream.read(buffer)) != -1) {
					bytesum += byteread;
					fs.write(buffer, 0, byteread);
				}
			}
			return bytesum;
		} catch (Exception e) {
			return 0;
		} finally {
			Util.ensureClosed(inStream);
			Util.ensureClosed(fs);
		}
	}
33526
public function shareFile($to, $file)
    {
        $parts[] = [
            'headers' => [
                'Content-Type' => $file['file_type'] ?: 'application/octet-stream',
            ],
            'name' => 'file',
            'contents' => stream_for($file['content']),
            'filename' => $file['filename'] ?: 'untitled',
        ];

        if (! str_empty($file['message'])) {
            $parts[] = [
                'headers' => [
                    'Content-Type' => 'application/json',
                ],
                'name' => 'metadata',
                'contents' => json_encode(['message' => $file['message']]),
            ];
        }

        $url = $this->url.'/v2/room/'.urlencode($to).'/share/file';

        return $this->postMultipartRelated($url, [
            'headers' => $this->getHeaders(),
            'multipart' => $parts,
        ]);
    }
644719
public function file( $file = null )
	{
		if ( !is_null( $file ) )
		{
			return $this->_file = $file;
		}
		
		return $this->_file;
	}
820665
public function copy($from, $to, array $config = [])
    {
        list($prefixFrom, $from) = $this->getPrefixAndPath($from);

        $buffer = $this->getFilesystem($prefixFrom)->readStream($from);

        if ($buffer === false) {
            return false;
        }

        list($prefixTo, $to) = $this->getPrefixAndPath($to);

        $result = $this->getFilesystem($prefixTo)->writeStream($to, $buffer, $config);

        if (is_resource($buffer)) {
            fclose($buffer);
        }

        return $result;
    }
972449
public static function copy(string $from, string $to) {
		ref\file::path($from, true);
		if (! $from) {
			return false;
		}

		ref\file::path($to, false);
		if (! $to || ($from === $to)) {
			return false;
		}

		// Recurse directories.
		if (@\is_dir($from)) {
			ref\file::trailingslash($from);
			ref\file::trailingslash($to);

			if (! @\is_dir($to)) {
				$dir_chmod = (@\fileperms($from) & 0777 | 0755);
				if (! static::mkdir($to, $dir_chmod)) {
					return false;
				}
			}

			// Copy all files and directories within.
			if ($handle = @\opendir($from)) {
				while (false !== ($file = @\readdir($handle))) {
					// Ignore dots.
					if (('.' === $file) || ('..' === $file)) {
						continue;
					}

					// Recurse.
					static::copy("{$from}{$file}", "{$to}{$file}");
				}
				\closedir($handle);
			}

			return true;
		}
		// Let PHP handle it.
		elseif (@\is_file($from)) {
			$dir_from = \dirname($from);
			$dir_to = \dirname($to);

			// Make the TO directory if it doesn't exist.
			if (! @\is_dir($dir_to)) {
				$dir_chmod = (@\fileperms($dir_from) & 0777 | 0755);
				if (! static::mkdir($dir_to, $dir_chmod)) {
					return false;
				}
			}

			// Copy the file.
			if (! @\copy($from, $to)) {
				return false;
			}
			$file_chmod = (@\fileperms($from) & 0777 | 0644);
			@\chmod($to, $file_chmod);

			return true;
		}

		return false;
	}
482073
public static void copyFile(File from, File to) throws RuntimeIOException {
		copyFile(from, to, false);
	}
658885
public function copy( $from, $to )
	{
		try {
			$this->fs->copy( $from, $to );
		} catch( \Exception $e ) {
			throw new Exception( $e->getMessage(), 0, $e );
		}
	}
260225
public function putFile(File $file, $newName = null)
    {
        if($file == null){
            return null;
        }
        $name = $newName == null?$file->getFilename():$newName;

        if(($f = $file->copy($this->folderPath."/".$name)) == null){
            return null;
        }


        return $f;

    }
246644
function copyFile(from, to) {
  return new Promise((resolve, reject) => {
    fs.copyFile(from, to, (err) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(to);
    });
  });
}
409358
public function copyDir($from,$to,Finder $finder)
    {
        /* @var \Symfony\Component\Finder\SplFileInfo $path */

        $finder->in($from);
        foreach ($finder->files() as $path) {
            $targetDir = $to.DIRECTORY_SEPARATOR.$path->getRelativePath();
            if (!is_dir($targetDir)) {
                mkdir($targetDir,0755,true);
            }
            $target = $to.DIRECTORY_SEPARATOR.$path->getRelativePathname();
            copy($path->getRealPath(),$target);
        }
    }
276777
public function setFile(File $file)
    {
        $this->file = $file;

        if ($this->file) {
            $this->updatedAt = new \DateTime('now');
        }

        return $this;
    }
483762
public function copyFrom($file, $source)
    {
        if ($this->enabled) {
            $file = preg_replace('{[^'.$this->whitelist.']}i', '-', $file);
            $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));

            if ($this->io->isDebug()) {
                $this->io->writeError('Writing '.$this->root . $file.' into cache');
            }

            return copy($source, $this->root . $file);
        }

        return false;
    }
482560
public static function download($from, $to): bool
    {
        /**
         * @var bool|resource $fromStream
         */
        $fromStream = File::open($from);

        if (!is_resource($fromStream))
        {
            throw new NotFound\Path('Stream `' . $from . '` not found');
        }

        if (!File::real($to) && !File::touch($to))
        {
            throw new Exceptions\PermissionDenied('File `' . $to . '`');
        }

        File::put($to, $fromStream);

        return File::close($fromStream);
    }
937229
private function copy(File $resource, ResourceNode $destParent)
    {
        $ds = DIRECTORY_SEPARATOR;
        $workspace = $destParent->getWorkspace();
        $newFile = new File();
        $newFile->setSize($resource->getSize());
        $newFile->setName($resource->getName());
        $newFile->setMimeType($resource->getMimeType());
        $hashName =  'WORKSPACE_' . $workspace->getId() .
            $ds .
            $this->container->get('claroline.utilities.misc')->generateGuid() .
            '.' .
            pathinfo($resource->getHashName(), PATHINFO_EXTENSION);
        $newFile->setHashName($hashName);
        $filePath = $this->container->getParameter('claroline.param.files_directory') . $ds . $resource->getHashName();
        $newPath = $this->container->getParameter('claroline.param.files_directory') . $ds . $hashName;
        $workspaceDir = $this->filesDir . $ds . 'WORKSPACE_' . $workspace->getId();

        if (!is_dir($workspaceDir)) {
            mkdir($workspaceDir);
        }
        copy($filePath, $newPath);

        return $newFile;
    }
606829
public function setFile($file): self
    {
        $this->file = $file;

        if (is_string($file)) {
            $this->pathToFile = $file;
            $this->setFileName(pathinfo($file, PATHINFO_BASENAME));
            $this->mediaName = pathinfo($file, PATHINFO_FILENAME);

            return $this;
        }

        if ($file instanceof UploadedFile) {
            $this->pathToFile = $file->getPath().'/'.$file->getFilename();
            $this->setFileName($file->getClientOriginalName());
            $this->mediaName = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);

            return $this;
        }

        if ($file instanceof SymfonyFile) {
            $this->pathToFile = $file->getPath().'/'.$file->getFilename();
            $this->setFileName(pathinfo($file->getFilename(), PATHINFO_BASENAME));
            $this->mediaName = pathinfo($file->getFilename(), PATHINFO_FILENAME);

            return $this;
        }

        throw UnknownType::create();
    }