100.00% Lines (2/2) 100.00% Functions (2/2)
TLA Baseline Branch
Line Hits Code Line Hits Code
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_RANDOM_ACCESS_FILE_SERVICE_HPP 10   #ifndef BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP
11   #define BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP 11   #define BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP
12   12  
13   #include <boost/corosio/detail/config.hpp> 13   #include <boost/corosio/detail/config.hpp>
14   #include <boost/corosio/random_access_file.hpp> 14   #include <boost/corosio/random_access_file.hpp>
15   #include <boost/capy/ex/execution_context.hpp> 15   #include <boost/capy/ex/execution_context.hpp>
16   16  
17   #include <filesystem> 17   #include <filesystem>
18   #include <system_error> 18   #include <system_error>
19   19  
20   namespace boost::corosio::detail { 20   namespace boost::corosio::detail {
21   21  
22   /** Abstract random-access file service base class. 22   /** Abstract random-access 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   */ 26   */
27   class BOOST_COROSIO_DECL random_access_file_service 27   class BOOST_COROSIO_DECL random_access_file_service
28   : public capy::execution_context::service 28   : public capy::execution_context::service
29   , public io_object::io_service 29   , public io_object::io_service
30   { 30   {
31   public: 31   public:
32   /// Identifies this service for `execution_context` lookup. 32   /// Identifies this service for `execution_context` lookup.
33   using key_type = random_access_file_service; 33   using key_type = random_access_file_service;
34   34  
35   /** Open a file. 35   /** Open a file.
36   36  
37   @param impl The file implementation to initialize. 37   @param impl The file implementation to initialize.
38   @param path The filesystem path to open. 38   @param path The filesystem path to open.
39   @param mode Bitmask of file_base::flags. 39   @param mode Bitmask of file_base::flags.
40   @return Error code on failure, empty on success. 40   @return Error code on failure, empty on success.
41   */ 41   */
42   virtual std::error_code open_file( 42   virtual std::error_code open_file(
43   random_access_file::implementation& impl, 43   random_access_file::implementation& impl,
44   std::filesystem::path const& path, 44   std::filesystem::path const& path,
45   file_base::flags mode) = 0; 45   file_base::flags mode) = 0;
46   46  
47   protected: 47   protected:
HITCBC 48   605 random_access_file_service() = default; 48   605 random_access_file_service() = default;
HITCBC 49   605 ~random_access_file_service() override = default; 49   605 ~random_access_file_service() override = default;
50   }; 50   };
51   51  
52   } // namespace boost::corosio::detail 52   } // namespace boost::corosio::detail
53   53  
54   #endif // BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP 54   #endif // BOOST_COROSIO_DETAIL_RANDOM_ACCESS_FILE_SERVICE_HPP