TLA Line data Source code
1 : //
2 : // Copyright (c) 2026 Michael Vandeberg
3 : //
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)
6 : //
7 : // Official repository: https://github.com/cppalliance/corosio
8 : //
9 :
10 : #ifndef BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP
11 : #define BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP
12 :
13 : #include <boost/corosio/detail/config.hpp>
14 : #include <boost/corosio/random_access_file.hpp>
15 : #include <boost/capy/ex/execution_context.hpp>
16 :
17 : #include <filesystem>
18 : #include <system_error>
19 :
20 : namespace boost::corosio::detail {
21 :
22 : /** Abstract random-access file service base class.
23 :
24 : Concrete implementations (posix, IOCP) inherit from
25 : this class and provide platform-specific file operations.
26 : */
27 : class BOOST_COROSIO_DECL random_access_file_service
28 : : public capy::execution_context::service
29 : , public io_object::io_service
30 : {
31 : public:
32 : /// Identifies this service for `execution_context` lookup.
33 : using key_type = random_access_file_service;
34 :
35 : /** Open a file.
36 :
37 : @param impl The file implementation to initialize.
38 : @param path The filesystem path to open.
39 : @param mode Bitmask of file_base::flags.
40 : @return Error code on failure, empty on success.
41 : */
42 : virtual std::error_code open_file(
43 : random_access_file::implementation& impl,
44 : std::filesystem::path const& path,
45 : file_base::flags mode) = 0;
46 :
47 : protected:
48 HIT 515 : random_access_file_service() = default;
49 515 : ~random_access_file_service() override = default;
50 : };
51 :
52 : } // namespace boost::corosio::detail
53 :
54 : #endif // BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP
|