77// Official repository: https://github.com/cppalliance/http_proto
88//
99
10- #ifndef BOOST_HTTP_PROTO_FILE_POSIX_HPP
11- #define BOOST_HTTP_PROTO_FILE_POSIX_HPP
10+ #ifndef BOOST_HTTP_PROTO_DETAIL_FILE_POSIX_HPP
11+ #define BOOST_HTTP_PROTO_DETAIL_FILE_POSIX_HPP
1212
1313#include < boost/http_proto/detail/config.hpp>
1414
2929#if BOOST_HTTP_PROTO_USE_POSIX_FILE
3030
3131#include < boost/http_proto/error.hpp>
32- #include < boost/http_proto/file_base .hpp>
32+ #include < boost/http_proto/file_mode .hpp>
3333#include < boost/system/error_code.hpp>
3434#include < cstdint>
3535
3636namespace boost {
3737namespace http_proto {
38+ namespace detail {
3839
39- /* * An implementation of File for POSIX systems.
40-
41- This class implements a <em>File</em> using POSIX interfaces.
42- */
40+ // Implementation of File for POSIX systems.
4341class file_posix
4442{
4543 int fd_ = -1 ;
@@ -50,141 +48,68 @@ class file_posix
5048 native_close (int & fd);
5149
5250public:
53- /* * The type of the underlying file handle.
54-
55- This is platform-specific.
56- */
5751 using native_handle_type = int ;
5852
59- /* * Destructor
60-
61- If the file is open it is first closed.
62- */
6353 BOOST_HTTP_PROTO_DECL
6454 ~file_posix ();
6555
66- /* * Constructor
67-
68- There is no open file initially.
69- */
7056 file_posix () = default ;
7157
72- /* * Constructor
73-
74- The moved-from object behaves as if default constructed.
75- */
7658 BOOST_HTTP_PROTO_DECL
7759 file_posix (
7860 file_posix&& other) noexcept ;
7961
80- /* * Assignment
81-
82- The moved-from object behaves as if default constructed.
83- */
8462 BOOST_HTTP_PROTO_DECL
8563 file_posix&
8664 operator =(
8765 file_posix&& other) noexcept ;
8866
89- // / Returns the native handle associated with the file.
9067 native_handle_type
9168 native_handle () const
9269 {
9370 return fd_;
9471 }
9572
96- /* * Set the native handle associated with the file.
97-
98- If the file is open it is first closed.
99-
100- @param fd The native file handle to assign.
101- */
10273 BOOST_HTTP_PROTO_DECL
10374 void
10475 native_handle (native_handle_type fd);
10576
106- // / Returns `true` if the file is open
10777 bool
10878 is_open () const
10979 {
11080 return fd_ != -1 ;
11181 }
11282
113- /* * Close the file if open
114-
115- @param ec Set to the error, if any occurred.
116- */
11783 BOOST_HTTP_PROTO_DECL
11884 void
11985 close (system::error_code& ec);
12086
121- /* * Open a file at the given path with the specified mode
122-
123- @param path The utf-8 encoded path to the file
124-
125- @param mode The file mode to use
126-
127- @param ec Set to the error, if any occurred
128- */
12987 BOOST_HTTP_PROTO_DECL
13088 void
13189 open (char const * path, file_mode mode, system::error_code& ec);
13290
133- /* * Return the size of the open file
134-
135- @param ec Set to the error, if any occurred
136-
137- @return The size in bytes
138- */
13991 BOOST_HTTP_PROTO_DECL
14092 std::uint64_t
14193 size (system::error_code& ec) const ;
14294
143- /* * Return the current position in the open file
144-
145- @param ec Set to the error, if any occurred
146-
147- @return The offset in bytes from the beginning of the file
148- */
14995 BOOST_HTTP_PROTO_DECL
15096 std::uint64_t
15197 pos (system::error_code& ec) const ;
15298
153- /* * Adjust the current position in the open file
154-
155- @param offset The offset in bytes from the beginning of the file
156-
157- @param ec Set to the error, if any occurred
158- */
15999 BOOST_HTTP_PROTO_DECL
160100 void
161101 seek (std::uint64_t offset, system::error_code& ec);
162102
163- /* * Read from the open file
164-
165- @param buffer The buffer for storing the result of the read
166-
167- @param n The number of bytes to read
168-
169- @param ec Set to the error, if any occurred
170- */
171103 BOOST_HTTP_PROTO_DECL
172104 std::size_t
173105 read (void * buffer, std::size_t n, system::error_code& ec) const ;
174106
175- /* * Write to the open file
176-
177- @param buffer The buffer holding the data to write
178-
179- @param n The number of bytes to write
180-
181- @param ec Set to the error, if any occurred
182- */
183107 BOOST_HTTP_PROTO_DECL
184108 std::size_t
185109 write (void const * buffer, std::size_t n, system::error_code& ec);
186110};
187111
112+ } // detail
188113} // http_proto
189114} // boost
190115
0 commit comments