Renames a file or directory

@param string $srcPath Source path
@param string $dstPath Destination path

@return boolean
160351
public function rename($srcPath, $dstPath)
  {
    $srcPartition = self::getPartition($srcPath);
    $dstPartition = self::getPartition($dstPath);

    if ($srcPartition != $dstPartition) {
      return false;
    }

    $srcRelativePath = self::getRelativePath($srcPath);
    $dstRelativePath = self::getRelativePath($dstPath);

    return !!$srcPartition->rename($srcRelativePath, $dstRelativePath);
  }
973243
public function rename($path, $newpath)
    {
        $newpath = static::normalizerPath($newpath);

        $this->writeStream($newpath, $this->readStream($path)['stream'], new Config() );

        $this->delete($path);

        return true;
    }
192887
public boolean rename(Path src, Path dst) throws IOException {
    return dfs.rename(getPathName(src), getPathName(dst));
  }
84231
public function rename($path, $newpath)
    {
        $statusCopy = $this->copy($path, $newpath);
        $statusRemoveOld = $this->delete($path);

        return $statusCopy && $statusRemoveOld;
    }
82512
public function renameRow(string $src, string $dst): bool
    {
        if (null === $this->data) {
            $this->buildIndex();
        }

        if ($this->hasKey($dst)) {
            throw new \RuntimeException("Cannot rename object: key '{$dst}' is already taken");
        }

        if (!$this->hasKey($src)) {
            return false;
        }

        // Change single key in the array without changing the order or value.
        $keys = array_keys($this->data);
        $keys[array_search($src, $keys, true)] = $dst;

        $this->data = array_combine($keys, $this->data);

        return true;
    }
419721
function move( $dstPath )
    {
        $srcPath = $this->filePath;

        eZDebugSetting::writeDebug( 'kernel-clustering', "fs::move( '$srcPath', '$dstPath' )", __METHOD__ );

        eZDebug::accumulatorStart( 'dbfile', false, 'dbfile' );
        eZFileHandler::move( $srcPath, $dstPath );
        eZDebug::accumulatorStop( 'dbfile' );
    }
796545
public static Action moveFileToEmptyPath(final String srcPath, final String destPath) {
        if (srcPath == null)
            throw new IllegalArgumentException("The srcPath variable cannot be null");
        if (destPath == null)
            throw new IllegalArgumentException("The destPath variable cannot be null");

        return new Action(
            // Perform:
            new ActionBlock() {
                @Override
                public void execute() throws ActionException {
                    File destFile = new File(destPath);
                    if (destFile.exists())
                        throw new ActionException("Cannot move file. " +
                                "The Destination file " + destPath + " already exists.");
                    boolean success = new File(srcPath).renameTo(destFile);
                    if (!success)
                        throw new ActionException("Cannot move file " + srcPath +
                                " to " + destPath);
                }
            },
            // Backout:
            new ActionBlock() {
                @Override
                public void execute() throws ActionException {
                    boolean success = new File(destPath).renameTo(new File(srcPath));
                    if (!success)
                        throw new ActionException("Cannot move file " + destPath +
                                " to " + srcPath);
                }
            },
            // Cleanup:
            null);
    }
473219
public function rename($path)
    {
        // This implementation supersedes the Flysystem's one. Indeed, while using connectors
        // such as the Amazon S3 (v3) connector, rename on directories does not work. A custom
        // implementation is then needed.
        $contents = $this->getFileSystem()->listContents($this->getPrefix(), true);

        // Filter files only.
        $filePaths = [];
        foreach ($contents as $content) {
            if ($content['type'] === 'file') {
                $filePaths[]= [
                    'source' => $content['path'],
                    'destination' => str_replace($this->getPrefix(), $path, $content['path'])];
            }
        }

        foreach ($filePaths as $renaming) {
            try {
                if ($this->getFileSystem()->rename($renaming['source'], $renaming['destination']) === false) {
                    throw new \common_exception_FileSystemError("Unable to rename '" . $this->getPrefix() . "' into '${path}'.");
                }
            } catch (FileExistsException $e) {
                throw new \common_exception_FileSystemError("Unable to rename '" . $this->getPrefix() . "' into '${path}'. File already exists.");
            }
        }

        if (!$this->deleteSelf()) {
            throw new \common_exception_FileSystemError("Could not finalize renaming of '" . $this->getPrefix() . "' into '${path}'.");
        }

        return true;
    }
421858
public function _copy( $srcFilePath, $dstFilePath, $fname = false )
    {
        if ( $fname )
            $fname .= "::_copy($srcFilePath, $dstFilePath)";
        else
            $fname = "_copy($srcFilePath, $dstFilePath)";

        // fetch source file metadata
        $metaData = $this->_fetchMetadata( $srcFilePath, $fname );
        // if source file does not exist then do nothing.
        // @todo Throw an exception here.
        //       Info: $srcFilePath
        if ( !$metaData )
        {
            return false;
        }
        $result = $this->_protect( array( $this, "_copyInner" ), $fname,
                                   $srcFilePath, $dstFilePath, $fname, $metaData );

        $this->eventHandler->notify( 'cluster/deleteFile', array( $dstFilePath ) );

        return $result;
    }
474994
public static function move($bucketName, $srcPath, $dstPath, $toOverWrite = 0)
    {
        $srcPath = self::normalizerPath($srcPath);
        $dstPath = self::normalizerPath($dstPath);

        $srcPath = self::cosUrlEncode($srcPath);
        $url = self::generateResUrl($bucketName, $srcPath);
        $sign = Auth::appSign_once($srcPath, $bucketName);

        $data = [
            'op'            => 'move',
            'dest_fileid'   => $dstPath,
            'to_over_write' => $toOverWrite,
        ];

        $data = json_encode($data);

        $req = [
            'url'     => $url,
            'method'  => 'post',
            'timeout' => self::$timeout,
            'data'    => $data,
            'header'  => [
                    'Authorization: '.$sign,
                    'Content-Type: application/json',
            ],
        ];

        return self::sendRequest($req);
    }
1189814
@Override
  public boolean rename(Path src, Path dst) throws IOException {
    FTPClient client = connect();
    try {
      boolean success = rename(client, src, dst);
      return success;
    } finally {
      disconnect(client);
    }
  }
300310
public function renameOnDFS( $oldPath, $newPath )
    {
        $this->accumulatorStart();

        $oldPath = $this->makeDFSPath( $oldPath );
        $newPath = $this->makeDFSPath( $newPath );

        $ret = eZFile::rename( $oldPath, $newPath, true );

        if ( $ret )
            eZClusterFileHandler::cleanupEmptyDirectories( $oldPath );

        $this->accumulatorStop();

        return $ret;
    }
1050920
def move(srcpath, dstpath, overwrite=True):
    """"""
    # TODO: (JRR@201612230924) Consider adding smarter checks to prevent files ending up with directory names; e.g. if dstpath directory does not exist.
    if not op.exists(srcpath):
        return False
    if srcpath == dstpath:
        return True
    if op.isfile(srcpath) and op.isdir(dstpath):
        verfunc = op.isfile
        verpath = op.join(dstpath, op.basename(srcpath))
    elif op.isfile(srcpath):
        verfunc = op.isfile
        verpath = dstpath
        makedirs(dstpath)
    elif op.isdir(srcpath) and op.isdir(dstpath):
        verfunc = op.isdir
        verpath = op.join(dstpath, op.basename(srcpath))
    elif op.isdir(srcpath):
        verfunc = op.isdir
        verpath = dstpath
    else:
        return False
    if op.isfile(verpath):
        if not overwrite:
            return False
        else:
            # On Windows, filename case is ignored so the following check will
            # prevent unintentionally deleting the srcpath before moving.
            if "nt" == os.name and srcpath.lower() == dstpath.lower():
                pass
            elif not delete(verpath):
                return False
    try:
        shutil.move(srcpath, dstpath)
    except:
        return False
    return verfunc(verpath)
1215581
def rename(src, dst):
    '''
    
    '''
    src = os.path.expanduser(src)
    dst = os.path.expanduser(dst)

    if not os.path.isabs(src):
        raise SaltInvocationError('File path must be absolute.')

    try:
        os.rename(src, dst)
        return True
    except OSError:
        raise CommandExecutionError(
            'Could not rename \'{0}\' to \'{1}\''.format(src, dst)
        )
    return False
124957
public function copyFromDFSToDFS( $srcFilePath, $dstFilePath )
    {
        $this->accumulatorStart();

        $srcFilePath = $this->makeDFSPath( $srcFilePath );
        $dstFilePath = $this->makeDFSPath( $dstFilePath );
        if ( file_exists( dirname( $dstFilePath ) ) )
        {
            $ret = copy( $srcFilePath, $dstFilePath );
            if ( $ret )
                $this->fixPermissions( $dstFilePath );
        }
        else
        {
            $ret = $this->createFile( $dstFilePath, fopen( $srcFilePath, 'rb' ), false );
        }

        $this->accumulatorStop();

        return $ret;
    }
527933
function rename( $destinationFilename, $sourceFilename = false )
    {
        if ( !$sourceFilename )
        {
            $wasOpen = $this->isOpen();
            if ( $wasOpen )
                $this->close();
            $result = $this->doRename( $destinationFilename, $this->filename() );
            if ( $wasOpen and
                 $result )
                $this->open( $destinationFilename, $this->mode() );
        }
        else
            $result = $this->doRename( $destinationFilename, $sourceFilename );
        return $result;
    }
1353576
public function _copy( $srcFilePath, $dstFilePath, $fname = false )
    {
        if ( $fname )
            $fname .= "::_copy($srcFilePath, $dstFilePath)";
        else
            $fname = "_copy($srcFilePath, $dstFilePath)";

        // fetch source file metadata
        $metaData = $this->_fetchMetadata( $srcFilePath, $fname );
        // if source file does not exist then do nothing.
        // @todo Throw an exception here.
        //       Info: $srcFilePath
        if ( !$metaData )
        {
            return false;
        }
        return $this->_protect( array( $this, "_copyInner" ), $fname,
                                $srcFilePath, $dstFilePath, $fname, $metaData );
    }