| ... | ... | @@ -34,25 +34,52 @@ else |
| 34 | 34 | Mode.blocking; |
| 35 | 35 | pub const is_async = mode != .blocking; |
| 36 | 36 | |
| 37 | fn getStdOutHandle() os.fd_t { |
| 38 | if (builtin.os == .windows) { |
| 39 | return os.windows.peb().ProcessParameters.hStdOutput; |
| 40 | } |
| 41 | |
| 42 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdOutHandle")) { |
| 43 | return root.os.io.getStdOutHandle(); |
| 44 | } |
| 45 | |
| 46 | return os.STDOUT_FILENO; |
| 47 | } |
| 48 | |
| 37 | 49 | pub fn getStdOut() File { |
| 50 | return File.openHandle(getStdOutHandle()); |
| 51 | } |
| 52 | |
| 53 | fn getStdErrHandle() os.fd_t { |
| 38 | 54 | if (builtin.os == .windows) { |
| 39 | | return File.openHandle(os.windows.peb().ProcessParameters.hStdOutput); |
| 55 | return os.windows.peb().ProcessParameters.hStdError; |
| 40 | 56 | } |
| 41 | | return File.openHandle(os.STDOUT_FILENO); |
| 57 | |
| 58 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdErrHandle")) { |
| 59 | return root.os.io.getStdErrHandle(); |
| 60 | } |
| 61 | |
| 62 | return os.STDERR_FILENO; |
| 42 | 63 | } |
| 43 | 64 | |
| 44 | 65 | pub fn getStdErr() File { |
| 66 | return File.openHandle(getStdErrHandle()); |
| 67 | } |
| 68 | |
| 69 | fn getStdInHandle() os.fd_t { |
| 45 | 70 | if (builtin.os == .windows) { |
| 46 | | return File.openHandle(os.windows.peb().ProcessParameters.hStdError); |
| 71 | return os.windows.peb().ProcessParameters.hStdInput; |
| 47 | 72 | } |
| 48 | | return File.openHandle(os.STDERR_FILENO); |
| 73 | |
| 74 | if (@hasDecl(root, "os") and @hasDecl(root.os, "io") and @hasDecl(root.os.io, "getStdInHandle")) { |
| 75 | return root.os.io.getStdInHandle(); |
| 76 | } |
| 77 | |
| 78 | return os.STDIN_FILENO; |
| 49 | 79 | } |
| 50 | 80 | |
| 51 | 81 | pub fn getStdIn() File { |
| 52 | | if (builtin.os == .windows) { |
| 53 | | return File.openHandle(os.windows.peb().ProcessParameters.hStdInput); |
| 54 | | } |
| 55 | | return File.openHandle(os.STDIN_FILENO); |
| 82 | return File.openHandle(getStdInHandle()); |
| 56 | 83 | } |
| 57 | 84 | |
| 58 | 85 | pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream; |