Copy file

@param string $src
@param string $rel_path

@return bool|string
359174
public function copy($src, $rel_path){
		$path = $this->setDir($rel_path);
		if( !($exist = file_exists($src)) ){
			trigger_error(sprintf('File %s doesn\'t exist.', $src), E_USER_WARNING);
		}
		return $path && $exist && copy($src, $path)
			? $path
			: false;
	}
698347
function copy(src, dest) {
    if (!src || !dest)
        return false;
    try {
        fs_extra_1.copySync(src, dest);
        logger_1.log.notify("copied " + src + " to " + dest + ".");
        return true;
    }
    catch (ex) {
        logger_1.log.warn("failed to copy " + src + " to " + dest + ".");
        return false;
    }
}
1004630
def copy_any(src, dst, only_missing=False):  # pragma: no cover
    """"""
    if not only_missing:
        remove_if_exist(dst)
    if os.path.exists(src):
        if os.path.isdir(src):
            if not only_missing:
                shutil.copytree(src, dst, symlinks=False, ignore=None)
            else:
                for dirpath, filepath in recwalk(src):
                    srcfile = os.path.join(dirpath, filepath)
                    relpath = os.path.relpath(srcfile, src)
                    dstfile = os.path.join(dst, relpath)
                    if not os.path.exists(dstfile):
                        create_dir_if_not_exist(os.path.dirname(dstfile))
                        shutil.copyfile(srcfile, dstfile)
                        shutil.copystat(srcfile, dstfile)
            return True
        elif os.path.isfile(src) and (not only_missing or not os.path.exists(dst)):
            shutil.copyfile(src, dst)
            shutil.copystat(src, dst)
            return True
    return False
612057
public static function copyr($src, $dst)
    {
        $dir = opendir($src);
        GeneratorHelper::createDir($dst);
        while (false !== ($file = readdir($dir))) {
            if (($file != '.') && ($file != '..')) {
                if (is_dir($src . '/' . $file)) {
                    self::copyr($src . '/' . $file, $dst . '/' . $file);
                } elseif (@copy($src . '/' . $file, $dst . '/' . $file) === false) {
                    throw new ConfigException("Can't copy " . $src . " to " . $dst);
                }
            }
        }
        closedir($dir);
    }
289524
public void copyToLocalFile(boolean delSrc, Path src, Path dst)
    throws IOException {
    fs.copyToLocalFile(delSrc, src, dst);
  }
846266
public function copyFile($bucket, $srcFpath, $dstFpath, $overwrite = false)
    {
        $url = self::generateResUrl($bucket, $srcFpath);
        $sign = $this->createNonreusableSignature($bucket, $srcFpath);
        $data = array(
            'op' => 'copy',
            'dest_fileid' => $dstFpath,
            'to_over_write' => $overwrite ? 1 : 0,
        );
        $req = array(
            'url' => $url,
            'method' => 'post',
            'timeout' => self::$timeout,
            'data' => $data,
            'header' => array(
                'Authorization: ' . $sign,
            ),
        );

        return self::sendRequest($req);
    }
97323
public function copy(PhingFile $src, PhingFile $dest)
    {
        global $php_errormsg;

        if (!$src->isLink()) {
            parent::copy($src, $dest);
            return;
        }

        $srcPath = $src->getAbsolutePath();
        $destPath = $dest->getAbsolutePath();

        $linkTarget = $src->getLinkTarget();
        if (false === @symlink($linkTarget, $destPath)) {
            $msg = "FileSystem::copy() FAILED. Cannot create symlink from $destPath to $linkTarget.";
            throw new Exception($msg);
        }
    }
297874
protected function recursiveCopy($src,$dst)
    {
        if($this->isZip($src)) { 
            $this->extractZip($src, $this->getInstallDir());
            return;
        }
        $dir = opendir($src); 
        if(!is_dir($dst)) {
            mkdir($dst);
        }
        while(false !== ( $file = readdir($dir)) ) { 
            if (( $file != '.' ) && ( $file != '..' )) { 
                if ( is_dir($src . '/' . $file) ) { 
                    recursiveCopy($src . '/' . $file,$dst . '/' . $file); 
                } 
                else { 
                    copy($src . '/' . $file,$dst . '/' . $file); 
                } 
            } 
        } 
        closedir($dir); 
    }
2867
public void copyFileFrom(InputStream src, boolean append) throws CopyFileFromException {
        ChannelSftp sftp;

        try {
            sftp = alloc();
            try {
                sftp.put(src, escape(slashPath), append ? ChannelSftp.APPEND : ChannelSftp.OVERWRITE);
            } finally {
                free(sftp);
            }
        } catch (SftpException | JSchException e) {
            throw new CopyFileFromException(this, e);
        }
    }
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();
	}
933685
public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
    throws IOException {
    fs.copyFromLocalFile(delSrc, src, dst);
  }
1130239
protected function copyTimestamp( $srcFilePath, $dstFilePath )
    {
        clearstatcache( true, $srcFilePath );
        $originalTimestamp = filemtime( $srcFilePath );
        if ( !$originalTimestamp )
        {
            return false;
        }

        return touch( $dstFilePath, $originalTimestamp);
    }
378863
public static void copyRecursive(Resource src, Resource trg, ResourceFilter filter) throws IOException {
	// print.out(src);
	// print.out(trg);
	if (!src.exists()) return;
	if (src.isDirectory()) {
	    if (!trg.exists()) trg.createDirectory(true);
	    Resource[] files = filter == null ? src.listResources() : src.listResources(filter);
	    if (files != null) for (int i = 0; i < files.length; i++) {
		copyRecursive(files[i], trg.getRealResource(files[i].getName()), filter);
	    }
	}
	else if (src.isFile()) {
	    touch(trg);
	    IOUtil.copy(src, trg);
	}
    }
185042
private static void copyToRemote(Path src, URI dst) throws IOException {
    ResourceId dstId = FileSystems.matchNewResource(dst.toString(), false);
    WritableByteChannel dstCh = FileSystems.create(dstId, MimeTypes.BINARY);
    FileChannel srcCh = FileChannel.open(src, StandardOpenOption.READ);
    long srcSize = srcCh.size();
    long copied = 0;
    do {
      copied += srcCh.transferTo(copied, srcSize - copied, dstCh);
    } while (copied < srcSize);
    dstCh.close();
    srcCh.close();
    Preconditions.checkState(copied == srcSize);
  }
281410
def _copy(src_file, dest_path):
  """"""
  tf.io.gfile.makedirs(os.path.dirname(dest_path))
  with tf.io.gfile.GFile(dest_path, 'wb') as dest_file:
    while True:
      data = src_file.read(io.DEFAULT_BUFFER_SIZE)
      if not data:
        break
      dest_file.write(data)
38539
protected static function copyRecursive( $src, $dest )
	{
		self::createDirectory( $dest );

		$iterator = new \RecursiveIteratorIterator(
			new \RecursiveDirectoryIterator( $src, \RecursiveDirectoryIterator::SKIP_DOTS ),
			\RecursiveIteratorIterator::SELF_FIRST
		);

		foreach( $iterator as $item )
		{
			$target = $dest . DIRECTORY_SEPARATOR . $iterator->getSubPathName();

			if( $item->isDir() === false )
			{
				if( copy( $item, $target ) === false ) {
					throw new \RuntimeException( sprintf( 'Unable to copy file "%1$s"', $item ) );
				}
			}
			else
			{
				self::createDirectory( $target );
			}
		}
	}
571061
public static function copy($src, $dest, $force = false)
	{
		if (is_dir($src)) {
			Dir::copy($src, $dest, $force);
		} elseif (is_file($src)) {
			File::copy($src, $dest, $force);
		}

		return true;
	}