Rename a file.

@param int $fileid The file ID.
@param string $newname The new file name.
@return object Box.net file object.
3271
public function rename_file($fileid, $newname) {
        // This requires a PUT request with data within it. We cannot use
        // the standard PUT request 'CURLOPT_PUT' because it expects a file.
        $data = array('name' => $newname);
        $options = array(
            'CURLOPT_CUSTOMREQUEST' => 'PUT',
            'CURLOPT_POSTFIELDS' => json_encode($data)
        );
        $url = $this->make_url("/files/$fileid");
        $this->reset_state();
        $result = $this->request($url, $options);
        $result = json_decode($result);
        return $result;
    }
1014566
public function cloneContent($id, $newId) {
    $path = $this->path . '/content/';
    if (file_exists($path . $id)) {
      self::copyFileTree($path . $id, $path . $newId);
    }
  }
624979
private function rename(string $oldPath, string $newPath): bool
    {
        if (!@rename($oldPath, $newPath)) {
            $message = 'Could not rename file.';
            if ($error = error_get_last()) {
                $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']);
            }
            throw new FileException($message);
        }

        return true;
    }
223449
public function renameTable($name, $newName)
    {
        $tableDiff          = new TableDiff($name);
        $tableDiff->newName = $newName;
        $this->alterTable($tableDiff);
    }
841082
public static File newFile(String fileName) {
		File file = new File(fileName);
		if(file.exists())
			file.delete();
		return file;
	}
450886
private function setNewFilename($newfilename = null)
    {
        $extension = $this->results['original_extension'];
        $originalFilename = $this->results['original_filename'];

        $timestamp = Carbon::now()->getTimestamp();

        switch ($this->newfilename) {
            case 'hash':
                $newfilename = md5($originalFilename.$timestamp);
                break;
            case 'random':
                $newfilename = Str::random(16);
                break;
            case 'timestamp':
                $newfilename = $timestamp;
                break;
            case 'custom':
                $newfilename = (! empty($newfilename) ? $newfilename : $originalFilename);
                break;
            default:
                $newfilename = pathinfo($originalFilename, PATHINFO_FILENAME);
        }

        $this->results['basename'] = (string) $newfilename;
        $this->results['filename'] = $newfilename.'.'.$extension;

        return $this;
    }
177433
public function rename($filepath, $filename) {
        if ($this->fs->file_exists($this->get_contextid(), $this->get_component(), $this->get_filearea(), $this->get_itemid(), $filepath, $filename)) {
            $a = new stdClass();
            $a->contextid = $this->get_contextid();
            $a->component = $this->get_component();
            $a->filearea  = $this->get_filearea();
            $a->itemid    = $this->get_itemid();
            $a->filepath  = $filepath;
            $a->filename  = $filename;
            throw new file_exception('storedfilenotcreated', $a, 'file exists, cannot rename');
        }
        $filerecord = new stdClass;
        $filerecord->filepath = $filepath;
        $filerecord->filename = $filename;
        // populate the pathname hash
        $filerecord->pathnamehash = $this->fs->get_pathname_hash($this->file_record->contextid, $this->file_record->component, $this->file_record->filearea, $this->file_record->itemid, $filepath, $filename);
        $this->update($filerecord);
    }
181468
public function rename(string $oldName, string $newName)
    {
        if (!@ftp_rename($this->ftp, $oldName, $newName)) {
            throw new Exception(sprintf("Cannot rename file from %s to %s", $oldName, $newName));
        }

        return $this;
    }
790257
public function rename( $new_file )
    {
        $res = @rename( $this->path, $new_file->getPath() );
        if ( $res === FALSE ){
            throw new FileRenameException($this, $new_file);
        }
    }
391779
public function rename($path, $newpath)
    {
        $pathinfo = pathinfo($path);
        if ($pathinfo['dirname'] != '.') {
            $path_remote = $pathinfo['dirname'] . '/' . $pathinfo['filename'];
        } else {
            $path_remote = $pathinfo['filename'];
        }

        $newpathinfo = pathinfo($newpath);
        if ($newpathinfo['dirname'] != '.') {
            $newpath_remote = $newpathinfo['dirname'] . '/' . $newpathinfo['filename'];
        } else {
            $newpath_remote = $newpathinfo['filename'];
        }

        $result = Uploader::rename($path_remote, $newpath_remote);

        return $result['public_id'] == $newpathinfo['filename'];
    }
253857
public function renameName($nameIndex, $newName)
    {
        $nameIndex = (int)$nameIndex;
        foreach ($this->positions as $position) {
            $source = $position->source;
            if ($source->nameIndex === $nameIndex) {
                $source->name = $newName;
            }
        }
    }
124597
public function renameColumn($oldName, $newName)
    {
        $this->getAdapter()->renameColumn($this->getName(), $oldName, $newName);

        return $this;
    }
789080
public static function rename(String $oldName, String $newName) : Bool
    {
        $oldName = Info::rpath($oldName);

        if( ! file_exists($oldName) )
        {
            throw new Exception\FileNotFoundException(NULL, $oldName);
        }

        return rename($oldName, $newName);
    }
481877
public function renameColumn($oldName, $newName)
    {
        if (isset($this[$oldName])) {
            $this[$newName] = $this[$oldName];
        }

        // outside the if () since we want to delete nulled columns
        if ($this->offsetExists($oldName)) {
            unset($this[$oldName]);
        }
    }
737741
private boolean renameOverwrite(String oldname, String newname) {

        boolean deleted = delete(newname);

        if (exists(oldname)) {
            File file = new File(oldname);

            return file.renameTo(new File(newname));
        }

        return deleted;
    }
86646
public static function rename(string $name, string $newName, bool $overwrite = true): void
	{
		NetteFileSystem::rename($name, $newName, $overwrite);
	}
62881
public function rename(string $newName) : bool
    {
        $renamed = rename($this->realPath, $newName);

        if ($renamed) {
            $this->realPath = realpath($newName);
        }

        return $renamed;
    }