** Check respons is valid
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzFtpClient::SetRemoteDir | (const hzString&,) |
Declared in file: hzFtpClient.h
Defined in file : hzFtpClient.cpp
Function Logic:
Function body:
hzEcode hzFtpClient::SetRemoteDir (const hzString& dir)
{
_hzfunc("hzFtpClient::SetRemoteDir") ;
hzString tgt ;
uint32_t nRecv ;
uint32_t len ;
uint32_t nTry ;
hzEcode rc ;
/*
** ** Check the directory is reasonable
** */
rc = _checkpath(tgt, m_ServerDir, dir) ;
if (rc != E_OK)
{
threadLog("In dir %s, acting on CD %s results in %s\n", *m_ServerDir, *dir, *tgt) ;
return rc ;
}
if (_hzGlobal_Debug & HZ_DEBUG_CLIENT)
threadLog("Tgt dir is %s\n", *tgt) ;
/*
** ** Send CWD command 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 CWD command, recv response
** */
sprintf(m_c_sbuf, "CWD %s\r\n", *dir) ;
len = strlen(m_c_sbuf) ;
if ((rc = m_ConnControl.Send(m_c_sbuf, len)) != E_OK)
{
threadLog("Could not send CWD command - Reconnecting ...\n") ;
continue ;
}
if ((rc = _ftprecv(nRecv, *_fn)) != E_OK)
{
threadLog("Could not recv CWD response - Reconnecting ...\n") ;
continue ;
}
break ;
}
if (rc == E_OK)
{
/*
** ** Check respons is valid
** */
if (m_nRescode == 250)
rc = E_OK ;
else
rc = E_NOTFOUND ;
}
if (rc == E_OK)
{
m_ServerDir = tgt ;
if (_hzGlobal_Debug & HZ_DEBUG_CLIENT)
threadLog("Remote dir is now %s\n", *m_ServerDir) ;
m_nTries = 0;
return E_OK ;
}
if (rc == E_NOTFOUND)
{
threadLog("Could not CD to %s (%s)\n", *tgt, m_c_rbuf) ;
return rc ;
}
threadLog("Failure report (err=%s)\n", Err2Txt(rc)) ;
return rc ;
}