From def5c50960eea4c112647f88361a3ae7155901a8 Mon Sep 17 00:00:00 2001 From: egor-tensin Date: Tue, 4 Jul 2023 00:48:00 +0000 Subject: =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20egor-tensin/wina?= =?UTF-8?q?pi-common@0c196cbe8b4927c78c02b2c7312fc69a507db845=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pipe_8cpp_source.html | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 pipe_8cpp_source.html (limited to 'pipe_8cpp_source.html') diff --git a/pipe_8cpp_source.html b/pipe_8cpp_source.html new file mode 100644 index 0000000..0b99a12 --- /dev/null +++ b/pipe_8cpp_source.html @@ -0,0 +1,125 @@ + + + + + + + +winapi_common: src/pipe.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
winapi_common +
+
+
+ + + + + + + + +
+
+ + +
+ +
+ + +
+
+
+
pipe.cpp
+
+
+
1 // Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
+
2 // This file is part of the "winapi-common" project.
+
3 // For details, see https://github.com/egor-tensin/winapi-common.
+
4 // Distributed under the MIT License.
+
5 
+
6 #include <winapi/error.hpp>
+
7 #include <winapi/handle.hpp>
+
8 #include <winapi/pipe.hpp>
+
9 
+
10 #include <windows.h>
+
11 
+
12 #include <cstring>
+
13 #include <utility>
+
14 
+
15 namespace winapi {
+
16 namespace {
+
17 
+
18 void create_pipe(Handle& read_end, Handle& write_end) {
+
19  HANDLE read_end_impl = INVALID_HANDLE_VALUE;
+
20  HANDLE write_end_impl = INVALID_HANDLE_VALUE;
+
21 
+
22  SECURITY_ATTRIBUTES attributes;
+
23  std::memset(&attributes, 0, sizeof(attributes));
+
24  attributes.nLength = sizeof(attributes);
+
25  attributes.bInheritHandle = TRUE;
+
26 
+
27  static constexpr DWORD buffer_size = 16 * 1024;
+
28 
+
29  const auto ret = ::CreatePipe(&read_end_impl, &write_end_impl, &attributes, buffer_size);
+
30 
+
31  if (!ret) {
+
32  throw error::windows(GetLastError(), "CreatePipe");
+
33  }
+
34 
+
35  read_end = Handle{read_end_impl};
+
36  write_end = Handle{write_end_impl};
+
37 }
+
38 
+
39 } // namespace
+
40 
+ +
42  create_pipe(m_read_end, m_write_end);
+
43 }
+
44 
+
45 } // namespace winapi
+ +
Make std::system_error work with GetLastError().
+
+ + + + -- cgit v1.2.3