From 8654bc18104d64c7a7f9f80bdba75ed4e0c005fa Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 20 Apr 2017 02:26:36 -0400 Subject: delete test_artifacts directory when tests complete * add std.os.deleteTree * add std.os.deleteDir * add std.os.page_size * add std.os API for iterating over directories * refactor duplication in build.zig * update documentation on how to run tests --- std/io.zig | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'std/io.zig') diff --git a/std/io.zig b/std/io.zig index 03960867b5..e9c70d9611 100644 --- a/std/io.zig +++ b/std/io.zig @@ -57,8 +57,6 @@ error NoMem; error Unseekable; error Eof; -const buffer_size = 4 * 1024; - pub const OpenRead = 0b0001; pub const OpenWrite = 0b0010; pub const OpenCreate = 0b0100; @@ -66,7 +64,7 @@ pub const OpenTruncate = 0b1000; pub const OutStream = struct { fd: i32, - buffer: [buffer_size]u8, + buffer: [os.page_size]u8, index: usize, /// `path` may need to be copied in memory to add a null terminating byte. In this case @@ -97,7 +95,7 @@ pub const OutStream = struct { } pub fn write(self: &OutStream, bytes: []const u8) -> %void { - if (bytes.len >= buffer_size) { + if (bytes.len >= self.buffer.len) { %return self.flush(); return os.posixWrite(self.fd, bytes); } @@ -329,7 +327,7 @@ pub const InStream = struct { } pub fn readAll(is: &InStream, buf: &Buffer0) -> %void { - %return buf.resize(buffer_size); + %return buf.resize(os.page_size); var actual_buf_len: usize = 0; while (true) { @@ -341,7 +339,7 @@ pub const InStream = struct { return buf.resize(actual_buf_len); } - %return buf.resize(actual_buf_len + buffer_size); + %return buf.resize(actual_buf_len + os.page_size); } } }; -- cgit v1.2.3