重命名文件

@param string $oldname
@param string $newname
@return boolean
@author yangyifan <yangyifanphp@gmail.com>
505185
public function rename($oldname, $newname)
    {
        $pathInfo       =  pathinfo($newname);
        $oldname        =  PathLibrary::normalizerPath($oldname);
        $newname        =  PathLibrary::normalizerPath($newname);
        $oldMetadata    =  $this->getMetadata($oldname);

        // 先递归创建目录
        if ( !empty($pathInfo['dirname']) ) {
            $this->createDir($pathInfo['dirname'], new Config());
        }

        $status =  Response::parseResponse(
            $this->getCos()->moveFile(
                $this->getBucket(),
                $oldname,
                $newname,
                self::FILE_TYPE
            )
        ) != false;

        if ( $status ) {

            //更新 自定义属性字段
            return Response::parseResponse(
                $this->getCos()->updateBase($this->getBucket(), $newname, self::FILE_TYPE, $oldMetadata['authority'], $oldMetadata['custom_headers'])
            ) != false;
        }

        return false;
    }
1258377
public function replace($old, $new)
    {
        $this->str = $this->str->replace((string)$old, (string)$new);

        return $this;
    }
253857
public function renameName($nameIndex, $newName)
    {
        $nameIndex = (int)$nameIndex;
        foreach ($this->positions as $position) {
            $source = $position->source;
            if ($source->nameIndex === $nameIndex) {
                $source->name = $newName;
            }
        }
    }
266627
public function renameCheck($oldName, $newName)
    {
        if (!$this->hasCheck($oldName)) {
            throw SchemaException::tableCheckDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasCheck($newName)) {
            throw SchemaException::tableCheckAlreadyExists($this->getName(), $newName);
        }

        $this->checks[$oldName]->setName($newName);
        $this->checks[$newName] = $this->checks[$oldName];
        unset($this->checks[$oldName]);
    }
1176107
function rename($oldname, $newname)
    {
        if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
            return false;
        }

        $oldname = $this->_realpath($oldname);
        $newname = $this->_realpath($newname);
        if ($oldname === false || $newname === false) {
            return false;
        }

        // http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3
        $packet = pack('Na*Na*', strlen($oldname), $oldname, strlen($newname), $newname);
        if (!$this->_send_sftp_packet(NET_SFTP_RENAME, $packet)) {
            return false;
        }

        $response = $this->_get_sftp_packet();
        if ($this->packet_type != NET_SFTP_STATUS) {
            user_error('Expected SSH_FXP_STATUS');
            return false;
        }

        // if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
        if (strlen($response) < 4) {
            return false;
        }
        extract(unpack('Nstatus', $this->_string_shift($response, 4)));
        if ($status != NET_SFTP_STATUS_OK) {
            $this->_logError($response, $status);
            return false;
        }

        // don't move the stat cache entry over since this operation could very well change the
        // atime and mtime attributes
        //$this->_update_stat_cache($newname, $this->_query_stat_cache($oldname));
        $this->_remove_from_stat_cache($oldname);
        $this->_remove_from_stat_cache($newname);

        return true;
    }
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;
    }
88886
public function renameColumn($oldName, $newName)
    {
        foreach ($this->getDataTables() as $table) {
            $table->renameColumn($oldName, $newName);
        }
    }
276432
public function setFileName($fileName = null) {
		if (empty($fileName)) {
			return false;
		}

		$this->_fileName = (string)$fileName;

		return true;
	}
510050
public function rename($path, $newPath)
    {
        try {
            return (bool) $this->api->rename($path, $newPath);
        } catch (\Exception $e) {
            return false;
        }
    }
1365687
public function renameFile($name, $newName)
    {
        foreach ($this->getAllFields() as $field) {
            $path = $this->getFilePath($field, $name);
            $newPath = $this->getFilePath($field, $newName);
            if (file_exists($newPath)) {
                throw new \Exception("File {$newName} already exists");
            }
            rename($path, $newPath);
        }
        if ($name == $this->owner->getAttribute($this->fileField)
            && ($files = $this->getFileList())
        ) {
            $this->owner->updateAttributes([$this->fileField => $newName]);
        }
        return true;
    }
321415
public function handle($old, $new)
    {
        if ( ! $this->canHandle($old) || ! $this->canHandle($new)) {
            return null;
        }

        if ($this->equals($old, $new)) {
            return false;
        }

        $this->lastException = new FailedConstraint(
            sprintf(
                '%s() body changed',
                $new->name
            )
        );

        return true;
    }
772774
public function update($old, $new): bool
    {
        if ($this->hasNot($old)) {
            return false;
        }

        $this->set($old, $new);

        return true;
    }
669213
public function renameColumn($oldName, $newName)
    {
        if (!$this->hasColumn($oldName)) {
            throw SchemaException::tableColumnDoesNotExist($this->getName(), $oldName);
        }

        if ($this->hasColumn($newName)) {
            throw SchemaException::tableColumnAlreadyExists($this->getName(), $newName);
        }

        $this->columns[$oldName]->setName($newName);
        $this->columns[$newName] = $this->columns[$oldName];
        unset($this->columns[$oldName]);
    }
1130367
public function changeUsername(string $newUsername) : bool {

		if ($this->isLoggedIn()) {

			$auth = new Authenticator($this->db);
			if ($auth->getUserFromUsername($newUsername) === null) {

				$stmt = $this->db->prepare(
					"UPDATE accounts SET username=? WHERE id=?;"
				);
				$stmt->bind_param("si", $newUsername, $this->id);
				$stmt->execute();
				$this->db->commit();
				$this->username = $newUsername;
				return true;
			} else {
				return false;
			}

		} else {
			return false;
		}
	}
260225
public function putFile(File $file, $newName = null)
    {
        if($file == null){
            return null;
        }
        $name = $newName == null?$file->getFilename():$newName;

        if(($f = $file->copy($this->folderPath."/".$name)) == null){
            return null;
        }


        return $f;

    }
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;
    }
190731
public static boolean isFileUpdate(String oldName, String newName) {

        return isFileEqual(new File(oldName), new File(newName));
    }