Renames src to dst. Src must not be equal to the filesystem root.

@param src Source path.
@param dst Destination path.
@return true if rename succeeds.
@throws FileNotFoundException if src does not exist.
@throws IOException if an error occurs.
179083
@Override
  public boolean rename(Path src, Path dst) throws IOException {
    // Even though the underlying GCSFS will also throw an IAE if src is root, since our filesystem
    // root happens to equal the global root, we want to explicitly check it here since derived
    // classes may not have filesystem roots equal to the global root.
    if (src.makeQualified(this).equals(getFileSystemRoot())) {
      logger.atFine().log("GHFS.rename: src is root: '%s'", src);
      return false;
    }

    long startTime = System.nanoTime();
    Preconditions.checkArgument(src != null, "src must not be null");
    Preconditions.checkArgument(dst != null, "dst must not be null");

    checkOpen();

    URI srcPath = getGcsPath(src);
    URI dstPath = getGcsPath(dst);
    logger.atFine().log("GHFS.rename: %s -> %s", src, dst);

    try {
      getGcsFs().rename(srcPath, dstPath);
    } catch (IOException e) {
      // Occasionally log exceptions that have a cause at info level,
      // because they could surface real issues and help with troubleshooting
      (logger.atFine().isEnabled() || e.getCause() == null
              ? logger.atFine()
              : logger.atInfo().atMostEvery(5, TimeUnit.MINUTES))
          .withCause(e)
          .log("Failed GHFS.rename: %s -> %s", src, dst);
      return false;
    }

    long duration = System.nanoTime() - startTime;
    increment(Counter.RENAME);
    increment(Counter.RENAME_TIME, duration);
    return true;
  }
1357077
public static boolean copyFile(final File src, final File dest)
    throws FileNotFoundException, IOException {
        return copyFile(src, dest, -1, true);
    }
434160
@Deprecated
  public void copyFromLocalFile(Path src, Path dst)
    throws IOException {
    copyFromLocalFile(false, true, false, src, dst);
  }
1050002
public boolean hardLink(String src, String dst) throws IOException {  
    checkOpen();  
    try { 
      return namenode.hardLink(src, dst); 
    } catch(RemoteException re) { 
      throw re.unwrapRemoteException(AccessControlException.class,  
                                     NSQuotaExceededException.class,  
                                     DSQuotaExceededException.class); 
    } 
  }
26967
@Deprecated
  public void copyFromLocalFile(boolean delSrc, Path src, Path dst)
    throws IOException {
    copyFromLocalFile(delSrc, true, src, dst);
  }
802892
def copy_dir(src, dst):
   
   try:
      debug.log("copy dir from "+ src, "to "+ dst)
      shutil.copytree(src, dst)
   except Exception as e:
      debug.log("Error: happened while copying!\n%s\n"%e)
1213838
public static long copyFile(File dst, File src) throws IOException {
		long copied;

		try (FileInputStream srcStream = new FileInputStream(src)) {
			copied = copyStream(dst, srcStream);
		}
		return copied;
	}
535969
def copy_file(src, dst, ignore=None):
   
   # Sanity checkpoint
   src = re.sub('[^\w/\-\.\*]', '', src)
   dst = re.sub('[^\w/\-\.\*]', '', dst)
   if len(re.sub('[\W]', '', src)) < 5 or len(re.sub('[\W]', '', dst)) < 5:
      debug.log("Error: Copying file failed. Provided paths are invalid! src='%s' dst='%s'"%(src, dst))
   else:
      # Check destination
      check = False
      if dst[-1] == '/':
         if os.path.exists(dst):
            check = True # Valid Dir
         else:
            debug.log("Error: Copying file failed. Destination directory does not exist (%s)"%(dst)) #DEBUG
      elif os.path.exists(dst):
         if os.path.isdir(dst):
            check = True # Valid Dir
            dst += '/' # Add missing slash
         else:
            debug.log("Error: Copying file failed. %s exists!"%dst)
      elif os.path.exists(os.path.dirname(dst)):
         check = True # Valid file path
      else:
         debug.log("Error: Copying file failed. %s is an invalid distination!"%dst)
      if check:
         # Check source
         files = glob.glob(src)
         if ignore is not None: files = [fil for fil in files if not ignore in fil]
         if len(files) != 0:
            debug.log("Copying File(s)...", "Copy from %s"%src, "to %s"%dst) #DEBUG
            for file_ in files:
               # Check file exists
               if os.path.isfile(file_):
                  debug.log("Copying file: %s"%file_) #DEBUG
                  shutil.copy(file_, dst)
               else:
                  debug.log("Error: Copying file failed. %s is not a regular file!"%file_) #DEBUG
         else: debug.log("Error: Copying file failed. No files were found! (%s)"%src)
577671
@Deprecated
  public void copyFromLocalFile(boolean delSrc, boolean overwrite, 
                                Path src, Path dst)
    throws IOException {
    copyFromLocalFile(delSrc, overwrite, false, src, dst);
  }
672081
public static void deleteDstAndRename(File srcFile, File dstFile) throws IOException
   {
      if (dstFile.exists())
      {
         if (!dstFile.delete())
         {
            throw new IOException("Cannot delete " + dstFile);
         }
      }

      renameFile(srcFile, dstFile);
   }
811074
public function publish($src, $dstDir) {
		$r = true;
		foreach(glob($src.'/*') as $file) {
			$dst = $dstDir.'/'.basename($file);
			if(!$this->copy($file, $dst))
				$r = false;
		}
		return $r;
	}
879172
public static function copy($src, $dst)
    {
        if (!is_dir($src)) {
            throw new RuntimeException(sprintf('Invalid directory path supplied "%s"', $src));
        }

        $dir = opendir($src);

        if (!is_dir($dst)) {
            mkdir($dst, 0777);
        }

        while (false !== ($file = readdir($dir))) {
            // We must ensure a file isn't a dot
            if (($file != '.' ) && ($file != '..' )) {
                if (is_dir($src . '/' . $file)) {
                    // Recursive call
                    call_user_func(__METHOD__, $src . '/' . $file, $dst . '/' . $file); 
                } else {
                    copy($src . '/' . $file, $dst . '/' . $file); 
                }
            }
        }

        closedir($dir);
        return true;
    }
24810
public void logRename(String src, String dst, long timestamp) {
    RenameOp op = RenameOp.getInstance();
    op.set(src, dst, timestamp);
    logEdit(op);
  }
1027978
public static void renamePath(FileSystem fs, Path oldName, Path newName) throws IOException {
    renamePath(fs, oldName, newName, false);
  }
361224
def copy(src, dst):
    
    if os.path.isdir(dst):
        dst = os.path.join(dst, os.path.basename(src))
    copyfile(src, dst)
    copymode(src, dst)
868054
def move_file(self, src, dst):
        

        src = self.get_full_file_path(src); dst = self.get_full_file_path(dst)

        # record where file moved
        if os.path.isfile(src):
            # if destination file exists, copy it to tmp first
            if os.path.isfile(dst):
                tmp_path = self.new_tmp()
                self.do_action({
                    'do'   : ['copy', dst, tmp_path],
                    'undo' : ['move', tmp_path, dst]})

        self.do_action(
            {'do'   : ['move', src, dst],
             'undo' : ['move', dst, src]})
113919
function (src, dst, callback) {

    if (fs.existsSync(dst)) {
        callback(src, dst);
    }
    else {
        fs.mkdirSync(dst);
        callback(src, dst);
    }
}