I tried this:
Response sf::Ftp::sendCommand(const string & ls "file.txt");
Response::getMessage();
Based on this article:
http://www.sfml-dev.org/documentation/2.2-fr/classsf_1_1Ftp.php
However, the code itself doesn't really sound logic in my ears + it just doesn't work.
This is the g++ output:
receive_chat.cpp: In function ‘int main()’:
receive_chat.cpp:18:1: error: ‘Response’ was not declared in this scope
Response sf::Ftp::sendCommand(const string & ls "file.txt");
^
receive_chat.cpp:18:10: error: expected ‘;’ before ‘sf’
Response sf::Ftp::sendCommand(const string & ls "file.txt");
^
receive_chat.cpp:19:1: error: ‘Response’ is not a class, namespace, or enumeration
Response::getMessage();
^
What is the right code?
Not sure where you got that code from but it doesn't seem to be from that article that you linked...
// Create a new FTP client
sf::Ftp ftp;
...
// Connect to the server
sf::Ftp::Response response = ftp.connect("ftp://ftp.myserver.com");
if (response.isOk())
std::cout << "Connected" << std::endl;
...
// Send specific commands (here: FEAT to list supported FTP features)
response = ftp.sendCommand("FEAT");
if (response.isOk())
std::cout << "Feature list:\n" << response.getMessage() << std::endl;
The SFML help-docs are really helpful.
Better then most C++ documentations I've seen.
Only this code:
sf::Ftp::ListingResponse response = ftp.getDirectoryListing();
if (response.isOk())
{
const std::vector<std::string>& listing = response.getListing();
for (std::vector<std::string>::const_iterator it = listing.begin(); it != listing.end(); ++it)
std::cout << "- " << *it << std::endl;
}
// you can also get the listing of a sub-directory of the current directory:
response = ftp.getDirectoryListing("subfolder");
On this page:
http://www.sfml-dev.org/tutorials/2.2/network-ftp.php
Isn't clear. Because it isn't really an example but more a wall of characters.
I personally like documentations more which really shows examples of how to use it, instead of using the type of variable. :)
Could also be laying at me.
That's definitely an example of how to use getDirectoryListing so I'm a bit confused. Are you trying to say the loop for printing out the std::vector<std::string> should be left out, because that's not really necessary once you know the type returned by getListing()? As in:
Getting the list of directories and files contained in the current directory:
sf::Ftp::ListingResponse response = ftp.getDirectoryListing();
if (response.isOk()) {
const std::vector<std::string>& listing = response.getListing();
}
You can also get the listing of a sub-directory of the current directory:
response = ftp.getDirectoryListing("subfolder");