/////////////////////////////////////////////////////// Entry point of application \return Application exit code ///////////////////////////////////////////////////////
| 33 | /// |
| 34 | //////////////////////////////////////////////////////////// |
| 35 | int main() |
| 36 | { |
| 37 | // Choose the server address |
| 38 | std::optional<sf::IpAddress> address; |
| 39 | do |
| 40 | { |
| 41 | std::cout << "Enter the FTP server address: "; |
| 42 | std::cin >> address; |
| 43 | } while (!address.has_value()); |
| 44 | |
| 45 | // Connect to the server |
| 46 | sf::Ftp server; |
| 47 | const sf::Ftp::Response connectResponse = server.connect(address.value()); |
| 48 | std::cout << connectResponse << std::endl; |
| 49 | if (!connectResponse.isOk()) |
| 50 | return EXIT_FAILURE; |
| 51 | |
| 52 | // Ask for user name and password |
| 53 | std::string user; |
| 54 | std::string password; |
| 55 | std::cout << "User name: "; |
| 56 | std::cin >> user; |
| 57 | std::cout << "Password: "; |
| 58 | std::cin >> password; |
| 59 | |
| 60 | // Login to the server |
| 61 | const sf::Ftp::Response loginResponse = server.login(user, password); |
| 62 | std::cout << loginResponse << std::endl; |
| 63 | if (!loginResponse.isOk()) |
| 64 | return EXIT_FAILURE; |
| 65 | |
| 66 | // Main menu |
| 67 | int choice = 0; |
| 68 | do |
| 69 | { |
| 70 | // Main FTP menu |
| 71 | std::cout << '\n' |
| 72 | << "Choose an action:\n" |
| 73 | << "1. Print working directory\n" |
| 74 | << "2. Print contents of working directory\n" |
| 75 | << "3. Change directory\n" |
| 76 | << "4. Create directory\n" |
| 77 | << "5. Delete directory\n" |
| 78 | << "6. Rename file\n" |
| 79 | << "7. Remove file\n" |
| 80 | << "8. Download file\n" |
| 81 | << "9. Upload file\n" |
| 82 | << "0. Disconnect\n" |
| 83 | << std::endl; |
| 84 | |
| 85 | std::cout << "Your choice: "; |
| 86 | std::cin >> choice; |
| 87 | std::cout << std::endl; |
| 88 | |
| 89 | switch (choice) |
| 90 | { |
| 91 | default: |
| 92 | { |
nothing calls this directly
no test coverage detected