Skip to content

Commit

Permalink
fix std.io.OutStream.close for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Oct 10, 2017
1 parent aa78827 commit 1f28d64
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions std/io.zig
Expand Up @@ -107,7 +107,7 @@ pub const OutStream = struct {
} else if (is_windows) {
@compileError("TODO: windows OutStream.openMode");
} else {
@compileError("Unsupported OS");
unreachable;
}

}
Expand Down Expand Up @@ -174,8 +174,14 @@ pub const OutStream = struct {
}

pub fn close(self: &OutStream) {
assert(self.index == 0);
os.posixClose(self.fd);
assert(self.index == 0); // unflushed buffer
if (is_posix) {
os.posixClose(self.fd);
} else if (is_windows) {
os.windowsClose(%%self.getHandle());
} else {
unreachable;
}
}

pub fn isTty(self: &OutStream) -> %bool {
Expand All @@ -188,7 +194,7 @@ pub const OutStream = struct {
} else if (is_windows) {
return os.windowsIsTty(%return self.getHandle());
} else {
@compileError("Unsupported OS");
unreachable;
}
}

Expand Down

0 comments on commit 1f28d64

Please sign in to comment.