重命名文件

@param $oldname
@param $newname
@return boolean
@author yangyifan <yangyifanphp@gmail.com>
973243
public function rename($path, $newpath)
    {
        $newpath = static::normalizerPath($newpath);

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

        $this->delete($path);

        return true;
    }
658611
public function rename($bucket, $oldname, $newname)
    {
        return $this->move($bucket, $oldname, $bucket, $newname);
    }
1198758
public function rename($filename, $newname, $try_another_name = false)
    {
        // Verificar se deve tentar outro nome caso ja exista
        if ($try_another_name)
        {
            $file_mask = preg_replace('/(.[a-zA-Z0-9]+)$/', '_%s\1', $filename);
            $contador = 1;
            while ($this->exists($newname))
            {
                $newname = sprintf($file_mask, $contador);
                $contador += 1;
            }
        }

        $this->copy($filename, $newname);
        $this->delete($filename);

        return $newname;
    }
326208
public function rename($oldName, $newName)
    {
        if (! ssh2_sftp_rename($this->sFtp, $oldName, $newName)) {
            throw new \RuntimeException('Name can not be changed');
        }
        return true;
    }
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]);
        }
    }
94402
public function move(string $old, string $new){
    if (
      !empty($old) &&
      !empty($new) &&
      ($old = $this->checkFilePath($old)) &&
      ftp_rename($this->cn, $old, $new)
    ){
      return true;
    }
    return false;
  }
124597
public function renameColumn($oldName, $newName)
    {
        $this->getAdapter()->renameColumn($this->getName(), $oldName, $newName);

        return $this;
    }
929722
public function rename($oldname, $newname) {
		$this->connectIfNeeded();
		$this->handle->rename($oldname, $newname);
		$this->onFileRenamed(
			new Event(['sender' => $this, 'data' => [
				'oldname' => $oldname, 
				'newname' => $newname
			]])
		);
	}
604289
public function rename($oldName, $newName)
    {
        if (! ftp_rename($this->session, $oldName, $newName)) {
            throw new \RuntimeException('Name can not be changed');
        }
        return true;
    }
752499
public static function classReplace($file, $oldName, $newName, $static = false)
    {
        $code = file_get_contents($file);
        $code = str_replace('<?php', '', $code);
        $code = str_replace('?>', '', $code);
        $code = preg_replace('/(final[\s]+)?class[\s]+' . preg_quote($oldName) . '/i', 'class ' . $newName, $code);

        if ($static !== false && $static !== 'self') {
            // TODO this is a ugly hack!
            $code = str_replace('static::', $static . '::', $code);
            $code = str_replace('self::', $static . '::', $code);
        }

        return $code;
    }
1006521
public function rename($old, $new)
    {
        return ($this->isConnected() === true) ? ftp_rename($this->getConnection(), $old, $new) : false;
    }
1256046
public function rename($path, $newPath)
    {
        if ($this->client->copyObject($this->bucket, $path, $this->bucket, $newPath) !== null) {
            $result = $this->client->deleteObject($this->bucket, $path);
            if (!is_null($result)) {
                return true;
            }
        }

        return false;
    }
78677
public function rename(string $newName, bool $replace = true): bool
    {
        //根据是否覆盖
        $ret = $replace ? $this->handle->rename($this->name, $newName) : $this->handle->renameNx($this->name, $newName);

        //如果改名成功,修改本对象的键
        if ($ret) {
            $this->name = $newName;
        }
        return $ret;
    }
125920
protected static function formatUsesPrefix($new, $old)
    {
        if (isset($new['namespace']) && isset($old['namespace'])) {
            return trim(array_get($old, 'namespace'), '\\') . '\\' . trim($new['namespace'], '\\');
        } elseif (isset($new['namespace'])) {
            return trim($new['namespace'], '\\');
        }
        
        return array_get($old, 'namespace');
    }
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;
    }
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;

    }
657310
public function rename($old_name, $new_name)
    {
        $old_name = $this->_getAbsoluteRemotePath($old_name);
        $new_name = $this->_getAbsoluteRemotePath($new_name);

        if (false === file_exists($old_name)) {
            return $this->_trigger_error(sprintf('Could not open remote file: %s.', $old_name));
        }

        if (true === file_exists($new_name)) {
            return $this->_trigger_error(sprintf('Remote file already exists: %s.', $new_name));
        }

        if (false === @rename($old_name, $new_name)) {
            return $this->_trigger_error(sprintf('Unable to rename %s to %s', $old_name, $new_name));
        }

        return true;
    }