| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2026 Michael Vandeberg
|
2 |
|
// Copyright (c) 2026 Michael Vandeberg
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/cppalliance/corosio
|
7 |
|
// Official repository: https://github.com/cppalliance/corosio
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#ifndef BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|
10 |
|
#ifndef BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|
| 11 |
|
#define BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|
11 |
|
#define BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|
| 12 |
|
|
12 |
|
|
| 13 |
|
#include <boost/corosio/detail/config.hpp>
|
13 |
|
#include <boost/corosio/detail/config.hpp>
|
| 14 |
|
#include <boost/corosio/stream_file.hpp>
|
14 |
|
#include <boost/corosio/stream_file.hpp>
|
| 15 |
|
#include <boost/capy/ex/execution_context.hpp>
|
15 |
|
#include <boost/capy/ex/execution_context.hpp>
|
| 16 |
|
|
16 |
|
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
|
19 |
|
|
| 20 |
|
namespace boost::corosio::detail {
|
20 |
|
namespace boost::corosio::detail {
|
| 21 |
|
|
21 |
|
|
| 22 |
|
/** Abstract stream file service base class.
|
22 |
|
/** Abstract stream file service base class.
|
| 23 |
|
|
23 |
|
|
| 24 |
|
Concrete implementations (posix, IOCP) inherit from
|
24 |
|
Concrete implementations (posix, IOCP) inherit from
|
| 25 |
|
this class and provide platform-specific file operations.
|
25 |
|
this class and provide platform-specific file operations.
|
| 26 |
|
The context constructor installs whichever backend via
|
26 |
|
The context constructor installs whichever backend via
|
| 27 |
|
`make_service`, and `stream_file.cpp` retrieves it via
|
27 |
|
`make_service`, and `stream_file.cpp` retrieves it via
|
| 28 |
|
`use_service<file_service>()`.
|
28 |
|
`use_service<file_service>()`.
|
| 29 |
|
|
29 |
|
|
| 30 |
|
class BOOST_COROSIO_DECL file_service
|
30 |
|
class BOOST_COROSIO_DECL file_service
|
| 31 |
|
: public capy::execution_context::service
|
31 |
|
: public capy::execution_context::service
|
| 32 |
|
, public io_object::io_service
|
32 |
|
, public io_object::io_service
|
| 33 |
|
|
33 |
|
|
| 34 |
|
|
34 |
|
|
| 35 |
|
/// Identifies this service for `execution_context` lookup.
|
35 |
|
/// Identifies this service for `execution_context` lookup.
|
| 36 |
|
using key_type = file_service;
|
36 |
|
using key_type = file_service;
|
| 37 |
|
|
37 |
|
|
| 38 |
|
|
38 |
|
|
| 39 |
|
|
39 |
|
|
| 40 |
|
Opens the file at the given path with the specified flags
|
40 |
|
Opens the file at the given path with the specified flags
|
| 41 |
|
and associates it with the platform I/O mechanism.
|
41 |
|
and associates it with the platform I/O mechanism.
|
| 42 |
|
|
42 |
|
|
| 43 |
|
@param impl The file implementation to initialize.
|
43 |
|
@param impl The file implementation to initialize.
|
| 44 |
|
@param path The filesystem path to open.
|
44 |
|
@param path The filesystem path to open.
|
| 45 |
|
@param mode Bitmask of file_base::flags.
|
45 |
|
@param mode Bitmask of file_base::flags.
|
| 46 |
|
@return Error code on failure, empty on success.
|
46 |
|
@return Error code on failure, empty on success.
|
| 47 |
|
|
47 |
|
|
| 48 |
|
virtual std::error_code open_file(
|
48 |
|
virtual std::error_code open_file(
|
| 49 |
|
stream_file::implementation& impl,
|
49 |
|
stream_file::implementation& impl,
|
| 50 |
|
std::filesystem::path const& path,
|
50 |
|
std::filesystem::path const& path,
|
| 51 |
|
file_base::flags mode) = 0;
|
51 |
|
file_base::flags mode) = 0;
|
| 52 |
|
|
52 |
|
|
| 53 |
|
|
53 |
|
|
| 54 |
|
file_service() = default;
|
54 |
|
file_service() = default;
|
| 55 |
|
~file_service() override = default;
|
55 |
|
~file_service() override = default;
|
| 56 |
|
|
56 |
|
|
| 57 |
|
|
57 |
|
|
| 58 |
|
} // namespace boost::corosio::detail
|
58 |
|
} // namespace boost::corosio::detail
|
| 59 |
|
|
59 |
|
|
| 60 |
|
#endif // BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|
60 |
|
#endif // BOOST_COROSIO_DETAIL_FILE_SERVICE_HPP
|