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;
    }
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;
    }
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 ; }
Renames a file or a directory on the SFTP server

@param string $oldname
@param string $newname
@return bool
@access public
Renames a file or a directory on the SFTP server