...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Note | |
---|---|
This feature requires I/O completion ports on Windows, and io_uring on
Linux (define |
Boost.Asio provides support for manipulating stream-oriented and random-access files. For example, to write to a newly created stream-oriented file:
boost::asio::stream_file file( my_io_context, "/path/to/file", boost::asio::stream_file::write_only | boost::asio::stream_file::create | boost::asio::stream_file::truncate); file.async_write_some(my_buffer, [](error_code e, size_t n) { // ... });
or to read from a random-access file:
boost::asio::random_access_file file( my_io_context, "/path/to/file", boost::asio::random_access_file::read_only); file.async_read_some_at(1234, my_buffer, [](error_code e, size_t n) { // ... });
basic_file, basic_random_access_file, basic_stream_file, file_base, random_access_file, stream_file.