| 181 | } |
| 182 | |
| 183 | Ftp::ListingResponse Ftp::getDirectoryListing( const std::string& directory ) { |
| 184 | // Open a data channel on default port (20) using ASCII transfer mode |
| 185 | std::ostringstream directoryData; |
| 186 | DataChannel data( *this ); |
| 187 | Response response = data.setup( Ascii ); |
| 188 | |
| 189 | if ( response.isOk() ) { |
| 190 | // Tell the server to send us the listing |
| 191 | response = sendCommand( "NLST", directory ); |
| 192 | |
| 193 | if ( response.isOk() ) { |
| 194 | // Receive the listing |
| 195 | data.receive( directoryData ); |
| 196 | |
| 197 | // Get the response from the server |
| 198 | response = getResponse(); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | return ListingResponse( response, directoryData.str() ); |
| 203 | } |
| 204 | |
| 205 | Ftp::Response Ftp::changeDirectory( const std::string& directory ) { |
| 206 | return sendCommand( "CWD", directory ); |