** The RNFR was OK so now send the RNTO
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzFtpClient::FileRename | (const hzString&,const hzString&,) |
Declared in file: hzFtpClient.h
Defined in file : hzFtpClient.cpp
Function Logic:
Function body:
hzEcode hzFtpClient::FileRename (const hzString& oldsvrname, const hzString& newsvrname)
{
_hzfunc("hzFtpClient::FileRename") ;
uint32_t nRecv ;
uint32_t len ;
uint32_t nTry ;
hzEcode rc ;
/*
** ** Send RNFR & RNTO commands and receive resposns, reconnect if required.
** */
for (nTry = 0; nTry < 2; nTry++)
{
if (nTry == 1)
{
m_ConnControl.Close() ;
rc = _reconnect() ;
if (rc != E_OK)
break ;
}
/*
** ** Send the RNFR (rename from) command and check the response
** */
sprintf(m_c_sbuf, "RNFR %s\r\n", *oldsvrname) ;
len = strlen(m_c_sbuf) ;
if ((rc = m_ConnControl.Send(m_c_sbuf, len)) != E_OK)
{
threadLog("Could not send RNFR command (file %s to %s)\n", *oldsvrname, *newsvrname) ;
continue ;
}
if ((rc = _ftprecv(nRecv, *_fn)) != E_OK)
{
threadLog("Could not get RNFR response (file %s to %s)\n", *oldsvrname, *newsvrname) ;
continue ;
}
if (m_nRescode == 350)
{
/*
** ** The RNFR was OK so now send the RNTO
** */
sprintf(m_c_sbuf, "RNTO %s\r\n", *newsvrname) ;
len = strlen(m_c_sbuf) ;
if ((rc = m_ConnControl.Send(m_c_sbuf, len)) != E_OK)
{
threadLog("Could not send RNTO command (file %s to %s)\n", *oldsvrname, *newsvrname) ;
continue ;
}
if ((rc = _ftprecv(nRecv, *_fn)) != E_OK)
{
threadLog("Could not get RNTO response (file %s to %s)\n", *oldsvrname, *newsvrname) ;
continue ;
}
}
break ;
}
/*
** ** Check server response
** */
if (m_nRescode >&eq; 400)
{
threadLog("Got bad response (%d) to RNFR/RNTO command (file %s to %s)\n", m_nRescode, *oldsvrname, *newsvrname) ;
return E_NODATA ;
}
return E_OK ;
}