Skip to content

Commit 1f28d64

Browse files
committed
fix std.io.OutStream.close for windows
1 parent aa78827 commit 1f28d64

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

std/io.zig

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ pub const OutStream = struct {
107107
} else if (is_windows) {
108108
@compileError("TODO: windows OutStream.openMode");
109109
} else {
110-
@compileError("Unsupported OS");
110+
unreachable;
111111
}
112112

113113
}
@@ -174,8 +174,14 @@ pub const OutStream = struct {
174174
}
175175

176176
pub fn close(self: &OutStream) {
177-
assert(self.index == 0);
178-
os.posixClose(self.fd);
177+
assert(self.index == 0); // unflushed buffer
178+
if (is_posix) {
179+
os.posixClose(self.fd);
180+
} else if (is_windows) {
181+
os.windowsClose(%%self.getHandle());
182+
} else {
183+
unreachable;
184+
}
179185
}
180186

181187
pub fn isTty(self: &OutStream) -> %bool {
@@ -188,7 +194,7 @@ pub const OutStream = struct {
188194
} else if (is_windows) {
189195
return os.windowsIsTty(%return self.getHandle());
190196
} else {
191-
@compileError("Unsupported OS");
197+
unreachable;
192198
}
193199
}
194200

0 commit comments

Comments
 (0)