Obtain the current working directory on the server Arguments: None
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzFtpClient::GetServerDir | (void) |
Declared in file: hzFtpClient.h
Defined in file : hzFtpClient.cpp
Function Logic:
Function body:
hzEcode hzFtpClient::GetServerDir (void)
{
// Obtain the current working directory on the server
//
// Arguments: None
//
// Returns: E_HOSTFAIL If there was a communication failure and reconnect failed
// E_PROTOCOL If the server did not respond as expected
// E_OK If the current working directory on the server was obtained
_hzfunc("hzFtpClient::GetServerDir") ;
char* i ; // Start of pathname (in quotes)
char* j ; // End of pathname (in quotes)
uint32_t nRecv ; // Bytes received
uint32_t len ; // Outgoing msg length
uint32_t nTry ; // Connection retries
hzEcode rc ; // Standard return code
/*
** ** Send PWD 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 PWD command, recv response
** */
sprintf(m_c_sbuf, "PWD\r\n") ;
len = strlen(m_c_sbuf) ;
if ((rc = m_ConnControl.Send(m_c_sbuf, len)) != E_OK)
{
threadLog("Could not send PWD command\n") ;
continue ;
}
if ((rc = _ftprecv(nRecv, *_fn)) != E_OK)
{
threadLog("Could not recv response to PWD command\n") ;
continue ;
}
break ;
}
if (rc == E_OK)
{
/*
** ** Check respons is valid
** */
_logrescode() ;
if (m_nRescode != 257)
{
threadLog("Expected a 257 return code, got %d\n", m_nRescode) ;
rc = E_PROTOCOL ;
}
}
if (rc == E_OK)
{
/*
** ** Set our record of the current server directory
** */
for (i = m_c_rbuf ; *i && *i != CHAR_DQUOTE ; i++)
if (*i)
{
i++ ;
for (j = i ; *j && *j != CHAR_DQUOTE ; j++) ;
*j = 0;
}
if (m_ServerDir != i)
m_ServerDir = i ;
m_nTries = 0;
return E_OK ;
}
threadLog("Could not get server directory\n") ;
return rc ;
}