ゴミ箱
file_win32.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
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/boostorg/beast
8 //
9 
10 #ifndef BOOST_BEAST_CORE_FILE_WIN32_HPP
11 #define BOOST_BEAST_CORE_FILE_WIN32_HPP
12 
13 #include <boost/config.hpp>
14 
15 #if ! defined(BOOST_BEAST_USE_WIN32_FILE)
16 # ifdef BOOST_MSVC
17 # define BOOST_BEAST_USE_WIN32_FILE 1
18 # else
19 # define BOOST_BEAST_USE_WIN32_FILE 0
20 # endif
21 #endif
22 
23 #if BOOST_BEAST_USE_WIN32_FILE
24 
27 #include <boost/detail/winapi/basic_types.hpp>
28 #include <boost/detail/winapi/handles.hpp>
29 #include <cstdio>
30 #include <cstdint>
31 
32 namespace boost {
33 namespace beast {
34 
39 class file_win32
40 {
41  boost::detail::winapi::HANDLE_ h_ =
42  boost::detail::winapi::INVALID_HANDLE_VALUE_;
43 
44 public:
49 #if BOOST_BEAST_DOXYGEN
50  using native_handle_type = HANDLE;
51 #else
52  using native_handle_type = boost::detail::winapi::HANDLE_;
53 #endif
54 
59  ~file_win32();
60 
65  file_win32() = default;
66 
71  file_win32(file_win32&& other);
72 
77  file_win32& operator=(file_win32&& other);
78 
80  native_handle_type
81  native_handle()
82  {
83  return h_;
84  }
85 
92  void
93  native_handle(native_handle_type h);
94 
96  bool
97  is_open() const
98  {
99  return h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_;
100  }
101 
106  void
107  close(error_code& ec);
108 
117  void
118  open(char const* path, file_mode mode, error_code& ec);
119 
126  std::uint64_t
127  size(error_code& ec) const;
128 
135  std::uint64_t
136  pos(error_code& ec);
137 
144  void
145  seek(std::uint64_t offset, error_code& ec);
146 
155  std::size_t
156  read(void* buffer, std::size_t n, error_code& ec);
157 
166  std::size_t
167  write(void const* buffer, std::size_t n, error_code& ec);
168 };
169 
170 } // beast
171 } // boost
172 
174 
175 #endif
176 
177 #endif
file_mode
Definition: file_base.hpp:26
Definition: async_result.hpp:20
boost::system::error_code error_code
The type of error code used by the library.
Definition: error.hpp:21