Downloading files

ftp->get_file("localfile", "remotefile");

ftp->get_file("localfile", 0644, "remotefile");

std::vector<char> buffer;

ftp->get(std::back_insert_iterator<std::vector<char>>(buffer), "remotefile");

get_file() downloads a file from the server, creating a local file. Optional file creation permission mode parameter follows the local filename parameter. get_file() creates a file with a temporary name, and renames it to localfile when the download finishes. An error throws an exception and removes the temporary file.

get() downloads a file and writes it to an output iterator, instead of a file. The remaining, optional parameters to get_file() and get():

  1. Binary transfer flag. The default value of true effects binary mode file transfer; false effects text mode file transfer. The text mode transfer makes no changes to the transferred contents. This specifies the mode setting for the transfer, and the transferred data gets saved in the file, as received from the server.

  2. x::fdtimeoutconfig that sets up the timeout configuration for the data channel used to transfer the requested file.