blob: 3a153700fe8d00f7c87d9aa3ad51b29c73f57f02 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2020 Egor Tensin <egor@tensin.name>
// This file is part of the "winapi-common" project.
// For details, see https://github.com/egor-tensin/winapi-common
// Distributed under the MIT License.
#pragma once
#include "handle.hpp"
#include "path.hpp"
#include "pipe.hpp"
#include <string_view>
#include <utility>
namespace winapi::process {
struct Stream {
Stream(Handle&& handle) : handle{std::move(handle)} {}
Handle handle;
};
/** @brief Redirect child process's stdin. */
struct Stdin : Stream {
/** No redirection. */
Stdin();
/** Make child process read form a file. */
explicit Stdin(std::string_view file);
/** @overload */
explicit Stdin(const CanonicalPath& file);
/** Make child process read form a pipe. */
explicit Stdin(Pipe&);
};
/** @brief Redirect child process's stdout. */
struct Stdout : Stream {
/** No redirection. */
Stdout();
/** Redirect child process's stdout to a file. */
explicit Stdout(std::string_view file);
/** @overload */
explicit Stdout(const CanonicalPath& file);
/** Redirect child process's stdout to a pipe. */
explicit Stdout(Pipe&);
};
/** @brief Redirect child process's stderr. */
struct Stderr : Stream {
/** No redirection. */
Stderr();
/** Redirect child process's stderr to a file. */
explicit Stderr(std::string_view file);
/** @overload */
explicit Stderr(const CanonicalPath& file);
/** Redirect child process's stderr to a pipe. */
explicit Stderr(Pipe&);
};
/** @brief Child process IO settings. */
struct IO {
IO() = default;
void close();
Stdin std_in;
Stdout std_out;
Stderr std_err;
};
} // namespace winapi::process
|