Copy a stream to target resource.

@param   string          $src  The source stream to copy, if is a path or resource, will auto create Stream
object.
@param   StreamInterface $dest The target stream.

@return  void
422328
public static function copyFrom($src, StreamInterface $dest)
    {
        $srcStream = $src instanceof StreamInterface ? $src : new Stream($src, Stream::MODE_READ_ONLY_FROM_BEGIN);

        static::copy($srcStream, $dest);

        $srcStream->close();
    }
1277775
public static Object copy(Object src, Object dest, int length) {
		System.arraycopy(src, 0, dest, 0, length);
		return dest;
	}
352712
public function copy( Table $src, Table $dest ) {

		$this->copy_structure( $src, $dest );
		$src_table  = $this->database->quote_identifier( $src->name() );
		$dest_table = $this->database->quote_identifier( $dest->name() );
		$query      = "INSERT INTO {$dest_table} SELECT * FROM {$src_table}";

		return (bool) $this->database->query( $query );
	}
1186935
public static function copyFile($src, $dst, $newFileMode = null)
    {
        copy($src, $dst);
        if (null !== $newFileMode) {
            @chmod($dst, $newFileMode);
        }
    }
339830
public function copyFile($container, $dest_path, $src_container, $src_path, $check_exist = false)
    {
        // does this file already exist?
        if (!$this->fileExists($src_container, $src_path)) {
            throw new NotFoundException("File '$src_path' does not exist.");
        }
        if ($this->fileExists($container, $dest_path)) {
            if (($check_exist)) {
                throw new BadRequestException("File '$dest_path' already exists.");
            }
        }
        // does this file's parent folder exist?
        $parent = FileUtilities::getParentFolder($dest_path);
        if (!empty($parent) && (!$this->folderExists($container, $parent))) {
            throw new NotFoundException("Folder '$parent' does not exist.");
        }

        // create the file
        $this->checkContainerForWrite($container); // need to be able to write to storage
        $this->copyBlob($container, $dest_path, $src_container, $src_path);
    }
958394
private function writePartContentTo(StreamInterface $stream)
    {
        $contentStream = $this->part->getContentStream();
        if ($contentStream !== null) {
            $copyStream = $this->streamFactory->newNonClosingStream($stream);
            $es = $this->getTransferEncodingDecoratorForStream($copyStream);
            $cs = $this->getCharsetDecoratorForStream($es);
            Psr7\copy_to_stream($contentStream, $cs);
            $cs->close();
        }
    }
166501
public static function copyRec($source, $dest) {
    if (is_file($source)) {
      $perms = fileperms($source);
      return copy($source, $dest) && chmod($dest, $perms);
    }
    if (!is_dir($source)) {
      $message = ObjectFactory::getInstance('message');
      throw new IllegalArgumentException($message->getText("Cannot copy %0% (it's neither a file nor a directory).", [$source]));
    }
    self::copyRecDir($source, $dest);
  }
90516
protected function copyFile($source, $dest)
    {
        // Ensure existing file can be overwritten
        if (file_exists($dest)) {
            $this->ensureWritable($dest);
        }
        file_put_contents($dest, file_get_contents($source));
    }
700072
protected function preserveAlpha($dest, $src)
    {
        $transparent = @imagecolortransparent($src);
        if (-1 != $transparent) {
            $color = @imagecolorsforindex($src, $transparent);
            $allocated = @imagecolorallocatealpha(
                            $dest
                            , $color['red']
                            , $color['green']
                            , $color['blue']
                            , $color['alpha']
            );
            @imagecolortransparent($dest, $allocated);
            @imagefill($dest, 0, 0, $allocated);
        }
    }
1003670
public static void copyFromFileToFile(File source, File dest) throws IOException{
		try {
			FileInputStream in = new FileInputStream(source);
			FileOutputStream out = new FileOutputStream(dest);
			try {
				FileChannel canalFuente = in.getChannel();
				FileChannel canalDestino = out.getChannel();
				canalFuente.transferTo(0, canalFuente.size(), canalDestino);
			} catch (IOException e) {
				throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
						+ "' destino:'" + dest.getAbsolutePath() + "'", e);
			} finally {
				IOUtils.closeQuietly(in);
				IOUtils.closeQuietly(out);
//				try { 
//					in.close();
//				} catch (IOException e) {
//				}
//				try {
//					out.close();
//				} catch (IOException e) {
//				}
			}
		} catch (FileNotFoundException e) {
			throw new IOException("copiando ficheros orig:'" + source.getAbsolutePath()
					+ "' destino:'" + dest.getAbsolutePath() + "'", e);
		}
	}
453124
public function copy($stream)
    {
        if($this->getResource())
        {
            if (!$stream instanceof KFilesystemStreamInterface && !is_resource($stream) && !get_resource_type($stream) == 'stream')
            {
                throw new InvalidArgumentException(sprintf(
                    'Stream must be on object implementing the FilesystemStreamInterface or a resource of type "stream".'
                ));
            }

            if($stream instanceof KFilesystemStreamInterface) {
                $resource = $stream->getResource();
            } else {
                $resource = $stream;
            }

            return fwrite($resource, $this->read());
        }

        return false;
    }
1070473
public function export($path, $dest)
    {
        $head = $this->getHead();
        $branch = $head->getName();

        $this->dispatch(VcsEvents::PRE_EXPORT, new ExportEventData($head, $path, $dest));

        if (!$this->hasCheckout) {
            $this->checkout();
        }

        // we already have cloned the repository, use that instead
        $result = $this->execute('clone', array('-b' => (string) $branch, '--depth=1', 'file://' . $this->cwd, $dest), getcwd());

        $result = $this->adapter->execute('submodule', array('update', '--init' => true, '--recursive' => true), $dest);

        $filesystem = new Filesystem();
        $filesystem->remove($dest . '/.git');

        $this->dispatch(VcsEvents::POST_EXPORT, new ExportEventData($head, $path, $dest));
    }
510716
public static function CopyFiles($source,$dest){
        File::mkfolders($dest);
        $folder = opendir($source);
        while($file = readdir($folder)){
            if ($file == '.' || $file == '..') continue;

            if(is_dir($source.'/'.$file)){
                mkdir($dest.'/'.$file,0777);
                $this->CopyFiles($source.'/'.$file,$dest.'/'.$file);
            }else copy($source.'/'.$file,$dest.'/'.$file);
        }
        closedir($folder);
        return 1;
    }
1333468
public static function copy_dir( $src_dir, $dest_dir ) {
		Process::create( Utils\esc_cmd( "cp -r %s/* %s", $src_dir, $dest_dir ) )->run_check();
	}
204999
private void copyFile(String path, File dest) {
        String resourceName= "native/" + path;
        try
        {
            LOG.debug("Copy from resource <"+resourceName+"> to target <"+dest.getAbsolutePath()+">");
            if (copy(getClass().getResourceAsStream(resourceName), dest.getAbsolutePath()))
            {
                if (dest.exists())
                {
                    LOG.debug("Target <"+dest.getAbsolutePath()+"> exists");
                }
                else
                {
                    LOG.fatal("Target <"+dest.getAbsolutePath()+"> does not exist");
                }
            }
            else
            {
                LOG.fatal("Copy resource to target <"+dest.getAbsolutePath()+"> failed");
            }
        }
        catch (NullPointerException ex)
        {
            LOG.error("Could not find ffmpeg executable for "+resourceName+" is the correct platform jar included?");
            throw ex;
        }
    }
1236494
public function copyBlob($container = '', $name = '', $src_container = '', $src_name = '', $properties = [])
    {
        $this->checkConnection();
        try {
            /** @var Container $src_container */
            $src_container = $this->blobConn->getContainer($src_container);
            if (empty($src_container)) {
                throw new \Exception("No container named '$src_container'");
            }
            /** @var Container $dest_container */
            $dest_container = $this->blobConn->getContainer($container);
            if (empty($dest_container)) {
                throw new \Exception("No container named '$container'");
            }

            $source = $src_container->DataObject($src_name);
            $destination = $dest_container->DataObject();
            $destination->setName($name);

            $source->Copy($destination);
        } catch (\Exception $ex) {
            static::handleGuzzleException($ex);
            throw new DfException("Failed to copy blob '$name': " . $ex->getMessage());
        }
    }
1186341
public static void copyFile(File src, File dest) throws IOException {

        if (src == null)
            throw new NullPointerException("Source must not be null");
        if (dest == null)
            throw new NullPointerException("Destination must not be null");
        if (!src.exists())
            throw new FileNotFoundException("Source '" + src + "' does not exist");
        if (!src.isFile())
            throw new IOException("Source '" + src + "' is not a file");
        if (dest.exists())
            throw new IOException("Destination '" + dest + "' is already exists");

        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(src).getChannel();
            out = new FileOutputStream(dest).getChannel();

            in.transferTo(0, in.size(), out);
        } finally {
            try {
                in.close();
                out.close();
            } catch (IOException e) {
                // Ignore.
            }
        }

        if (src.length() != dest.length()) {
            throw new IOException("Failed to copy full contents from '" +
                src + "' to '" + dest + "'");
        }

        dest.setLastModified(src.lastModified());
    }