diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-05-26 13:17:34 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-05-26 18:32:44 -0400 |
| commit | 2f040a23c8b968db56ab4c4725d6651f5ea3418e (patch) | |
| tree | 58727a1c2ffdf356db2f5c01e84940e4ced0541f /std/io.zig | |
| parent | 7cb6279ac0cec065234347bda5944be64fe8b3da (diff) | |
| download | zig-2f040a23c8b968db56ab4c4725d6651f5ea3418e.tar.gz zig-2f040a23c8b968db56ab4c4725d6651f5ea3418e.zip | |
clean up references to os
Diffstat (limited to 'std/io.zig')
| -rw-r--r-- | std/io.zig | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/std/io.zig b/std/io.zig index 5ca011cb4c..41dc38f245 100644 --- a/std/io.zig +++ b/std/io.zig @@ -15,8 +15,31 @@ const fmt = std.fmt; const File = std.fs.File; const testing = std.testing; -const is_posix = builtin.os != builtin.Os.windows; -const is_windows = builtin.os == builtin.Os.windows; +pub const GetStdIoError = os.windows.GetStdHandleError; + +pub fn getStdOut() GetStdIoError!File { + if (os.windows.is_the_target) { + const handle = try os.windows.GetStdHandle(os.windows.STD_OUTPUT_HANDLE); + return File.openHandle(handle); + } + return File.openHandle(os.STDOUT_FILENO); +} + +pub fn getStdErr() GetStdIoError!File { + if (os.windows.is_the_target) { + const handle = try os.windows.GetStdHandle(os.windows.STD_ERROR_HANDLE); + return File.openHandle(handle); + } + return File.openHandle(os.STDERR_FILENO); +} + +pub fn getStdIn() GetStdIoError!File { + if (os.windows.is_the_target) { + const handle = try os.windows.GetStdHandle(os.windows.STD_INPUT_HANDLE); + return File.openHandle(handle); + } + return File.openHandle(os.STDIN_FILENO); +} pub const SeekableStream = @import("io/seekable_stream.zig").SeekableStream; pub const SliceSeekableInStream = @import("io/seekable_stream.zig").SliceSeekableInStream; |
