A cross-platform FTP/FTPS client library based on Boost.Asio
MIT License
A cross-platform FTP/FTPS client library based on Boost.Asio.
FTP (File Transfer Protocol) is a standard network protocol used to transfer files between a client and a server. FTP is built on a client-server model and uses separate connections for transferring commands and files.
The transfer mode determines how the data connection is established.
The transfer type determines how data is transferred.
CRLF
style, and the receiving side performs theDownload the README.TXT
file from ftp.freebsd.org and output its contents to stdout
:
#include <iostream>
#include <sstream>
#include <ftp/ftp.hpp>
int main(int argc, char *argv[])
{
ftp::client client;
client.connect("ftp.freebsd.org", 21, "anonymous");
std::ostringstream oss;
client.download_file(ftp::ostream_adapter(oss), "pub/FreeBSD/README.TXT");
std::cout << oss.str();
client.disconnect();
return 0;
}
See more examples in the example folder.
This library can be integrated into a project via CMake's FetchContent
, for example:
cmake_minimum_required(VERSION 3.14)
project(application)
include(FetchContent)
FetchContent_Declare(
libftp
GIT_REPOSITORY https://github.com/deniskovalchuk/libftp.git
GIT_TAG v1.1.0)
FetchContent_MakeAvailable(libftp)
add_executable(application main.cpp)
target_link_libraries(application ftp::ftp)
Build and run tests:
tool/windows/build.ps1 [-BuildType Debug|Release] [-RunTest]
Clean the builds:
tool/windows/clean.ps1
Build and run tests:
tool/unix/build.sh [--debug | --release] [--test]
Clean the builds:
tool/unix/clean.sh
Build:
$ mkdir -p build
$ cd build
$ cmake ..
$ cmake --build .
To run tests, set the LIBFTP_TEST_SERVER_PATH
environment variable to the path to the
server.py file:
$ export LIBFTP_TEST_SERVER_PATH="/path/to/server.py"
$ cd test
$ ctest -V