Obtain the current working directory on the server Arguments: None

Return TypeFunction nameArguments
hzEcodehzFtpClient::GetServerDir(void)

Declared in file: hzFtpClient.h
Defined in file : hzFtpClient.cpp

Function Logic:

0:START 1:unknown 2:unknown 3:items rc 4:unknown 5:items len 6:unknown 7:items 8:unknown 9:items 10:unknown 11:items 12:unknown 13:items rc 14:unknown 15:unknown 16:unknown 17:items 18:unknown 19:* 20:unknown 21:m_ServerDir 22:m_nTries 23:Return E_OK 24:items 25:Return rc

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 ;
}