blob: 5b82005145e0941832522d11966c8b41f1e5c457 [file] [log] [blame]
[email protected]922c8e92013-05-30 05:20:291// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
avic5960f32015-12-22 22:49:485#include "build/build_config.h"
[email protected]922c8e92013-05-30 05:20:296#include "remoting/host/setup/test_util.h"
7
8#if defined(OS_WIN)
9#include <windows.h>
10#elif defined(OS_POSIX)
11#include <unistd.h>
12#endif
13
14namespace remoting {
15
[email protected]0fa0bbf2014-05-02 04:28:0016bool MakePipe(base::File* read_file,
17 base::File* write_file) {
[email protected]922c8e92013-05-30 05:20:2918#if defined(OS_WIN)
[email protected]0fa0bbf2014-05-02 04:28:0019 base::PlatformFile read_handle;
20 base::PlatformFile write_handle;
sergeyuc5f104b2015-01-09 19:33:2421 if (!CreatePipe(&read_handle, &write_handle, nullptr, 0))
[email protected]0fa0bbf2014-05-02 04:28:0022 return false;
23 *read_file = base::File(read_handle);
24 *write_file = base::File(write_handle);
25 return true;
[email protected]922c8e92013-05-30 05:20:2926#elif defined(OS_POSIX)
27 int fds[2];
28 if (pipe(fds) == 0) {
[email protected]0fa0bbf2014-05-02 04:28:0029 *read_file = base::File(fds[0]);
30 *write_file = base::File(fds[1]);
[email protected]922c8e92013-05-30 05:20:2931 return true;
32 }
33 return false;
34#else
35#error Not implemented
36#endif
37}
38
David Sandersbb0d6af2021-12-22 13:25:5539} // namespace remoting