123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- #ifndef BOOST_BEAST_CORE_FILE_POSIX_HPP
- #define BOOST_BEAST_CORE_FILE_POSIX_HPP
- #include <boost/beast/core/detail/config.hpp>
- #if ! defined(BOOST_BEAST_NO_POSIX_FILE)
- # if ! defined(__APPLE__) && ! defined(__linux__)
- # define BOOST_BEAST_NO_POSIX_FILE
- # endif
- #endif
- #if ! defined(BOOST_BEAST_USE_POSIX_FILE)
- # if ! defined(BOOST_BEAST_NO_POSIX_FILE)
- # define BOOST_BEAST_USE_POSIX_FILE 1
- # else
- # define BOOST_BEAST_USE_POSIX_FILE 0
- # endif
- #endif
- #if BOOST_BEAST_USE_POSIX_FILE
- #include <boost/beast/core/error.hpp>
- #include <boost/beast/core/file_base.hpp>
- #include <cstdint>
- namespace boost {
- namespace beast {
- class file_posix
- {
- int fd_ = -1;
- BOOST_BEAST_DECL
- static
- int
- native_close(int& fd);
- public:
-
- using native_handle_type = int;
-
- BOOST_BEAST_DECL
- ~file_posix();
-
- file_posix() = default;
-
- BOOST_BEAST_DECL
- file_posix(file_posix&& other);
-
- BOOST_BEAST_DECL
- file_posix& operator=(file_posix&& other);
-
- native_handle_type
- native_handle() const
- {
- return fd_;
- }
-
- BOOST_BEAST_DECL
- void
- native_handle(native_handle_type fd);
-
- bool
- is_open() const
- {
- return fd_ != -1;
- }
-
- BOOST_BEAST_DECL
- void
- close(error_code& ec);
-
- BOOST_BEAST_DECL
- void
- open(char const* path, file_mode mode, error_code& ec);
-
- BOOST_BEAST_DECL
- std::uint64_t
- size(error_code& ec) const;
-
- BOOST_BEAST_DECL
- std::uint64_t
- pos(error_code& ec) const;
-
- BOOST_BEAST_DECL
- void
- seek(std::uint64_t offset, error_code& ec);
-
- BOOST_BEAST_DECL
- std::size_t
- read(void* buffer, std::size_t n, error_code& ec) const;
-
- BOOST_BEAST_DECL
- std::size_t
- write(void const* buffer, std::size_t n, error_code& ec);
- };
- }
- }
- #ifdef BOOST_BEAST_HEADER_ONLY
- #include <boost/beast/core/impl/file_posix.ipp>
- #endif
- #endif
- #endif
|