classes/CFTP.cpp
//
// Return true if passed in file is a directory false for a file.
//
Return true if passed in file is a directory false for a file.
Return true if passed in file is a directory false for a file .
bool CFTP::isDirectory(const std::string &fileName)
    {
        try
        {
            if (!m_connected)
            {
                throw std::logic_error("Already connected to a server.");
            }
            ftpCommand("MLST " + fileName);
            if (m_commandStatusCode == 250)
            {
                size_t dirPosition = m_commandResponse.find("Type=dir;");
                if (dirPosition != std::string::npos)
                {
                    return (true);
                }
            }
            else if (m_commandStatusCode == 500)
            {
                ftpCommand("STAT " + fileName);
                if ((m_commandStatusCode == 213) || (m_commandStatusCode == 212))
                {
                    size_t dirPosition = m_commandResponse.find("\r\n") + 2;
                    if ((dirPosition != std::string::npos) &&
                        (m_commandResponse[dirPosition] == 'd'))
                    {
                        return (true);
                    }
                }
            }
            return (false);
        }
        catch (const std::exception &e)
        {
            throw Exception(e.what());
        }
    }
bool CFTP :: isDirectory ( const std :: string & fileName ) { try { if ( ! m_connected ) { throw std :: logic_error ( " " ) ; } ftpCommand ( " " + fileName ) ; if ( m_commandStatusCode == 250 ) { size_t dirPosition = m_commandResponse . find ( " " ) ; if ( dirPosition != std :: string :: npos ) { return ( true ) ; } } else if ( m_commandStatusCode == 500 ) { ftpCommand ( " " + fileName ) ; if ( ( m_commandStatusCode == 213 ) || ( m_commandStatusCode == 212 ) ) { size_t dirPosition = m_commandResponse . find ( " \r \n " ) + 2 ; if ( ( dirPosition != std :: string :: npos ) && ( m_commandResponse [ dirPosition ] == ' ' ) ) { return ( true ) ; } } } return ( false ) ; } catch ( const std :: exception & e ) { throw Exception ( e . what ( ) ) ; } }
Return true if passed in file is a directory false for a file.
Return true if passed in file is a directory false for a file .
// Try MLST first then STAT