classes/CFTP.cpp
std::uint16_t CFTP::listFiles(const std::string &directoryPath, FileList &fileList)
    {
        try
        {
            if (!m_connected)
            {
                throw std::logic_error("Already connected to a server.");
            }
            fileList.clear();
            if (sendTransferMode())
            {
                std::string listOutput;
                ftpCommand("NLST " + directoryPath);
                transferOnDataChannel(listOutput);
                if (m_commandStatusCode == 226)
                {
                    std::string file;
                    std::istringstream listOutputStream{listOutput};
                    while (std::getline(listOutputStream, file, '\n'))
                    {
                        file.pop_back();
                        fileList.push_back(file);
                    }
                }
            }
            return (m_commandStatusCode);
        }
        catch (const std::exception &e)
        {
            throw Exception(e.what());
        }
    }
//
// Produce a file list for the file/directory passed in or for the current
// working directory if none is.
//
Produce a file list for the file/directory passed in or for the current
working directory if none is.
Produce a file list for the file / directory passed in or for the current working directory if none is .
std::uint16_t CFTP::listFiles(const std::string &directoryPath, FileList &fileList)
    {
        try
        {
            if (!m_connected)
            {
                throw std::logic_error("Already connected to a server.");
            }
            fileList.clear();
            if (sendTransferMode())
            {
                std::string listOutput;
                ftpCommand("NLST " + directoryPath);
                transferOnDataChannel(listOutput);
                if (m_commandStatusCode == 226)
                {
                    std::string file;
                    std::istringstream listOutputStream{listOutput};
                    while (std::getline(listOutputStream, file, '\n'))
                    {
                        file.pop_back();
                        fileList.push_back(file);
                    }
                }
            }
            return (m_commandStatusCode);
        }
        catch (const std::exception &e)
        {
            throw Exception(e.what());
        }
    }
std :: uint16_t CFTP :: listFiles ( const std :: string & directoryPath , FileList & fileList ) { try { if ( ! m_connected ) { throw std :: logic_error ( " " ) ; } fileList . clear ( ) ; if ( sendTransferMode ( ) ) { std :: string listOutput ; ftpCommand ( " " + directoryPath ) ; transferOnDataChannel ( listOutput ) ; if ( m_commandStatusCode == 226 ) { std :: string file ; std :: istringstream listOutputStream { listOutput } ; while ( std :: getline ( listOutputStream , file , ' \n ' ) ) { file . pop_back ( ) ; fileList . push_back ( file ) ; } } } return ( m_commandStatusCode ) ; } catch ( const std :: exception & e ) { throw Exception ( e . what ( ) ) ; } }
Produce a file list for the file/directory passed in or for the current
working directory if none is.
Produce a file list for the file / directory passed in or for the current working directory if none is .