aboutsummaryrefslogtreecommitdiff
path: root/std/io.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-05-26 13:17:34 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-05-26 18:32:44 -0400
commit2f040a23c8b968db56ab4c4725d6651f5ea3418e (patch)
tree58727a1c2ffdf356db2f5c01e84940e4ced0541f /std/io.zig
parent7cb6279ac0cec065234347bda5944be64fe8b3da (diff)
downloadzig-2f040a23c8b968db56ab4c4725d6651f5ea3418e.tar.gz
zig-2f040a23c8b968db56ab4c4725d6651f5ea3418e.zip
clean up references to os
Diffstat (limited to 'std/io.zig')
-rw-r--r--std/io.zig27
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;