diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 02:26:36 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-04-20 02:26:36 -0400 |
| commit | 8654bc18104d64c7a7f9f80bdba75ed4e0c005fa (patch) | |
| tree | 398f7b9d18988b61ad12db21aa72e21da3aec4d4 /std/io.zig | |
| parent | 1ff73a8e69a09b3bc993cffb755cc2ca98c7040b (diff) | |
| download | zig-8654bc18104d64c7a7f9f80bdba75ed4e0c005fa.tar.gz zig-8654bc18104d64c7a7f9f80bdba75ed4e0c005fa.zip | |
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
Diffstat (limited to 'std/io.zig')
| -rw-r--r-- | std/io.zig | 10 |
1 files changed, 4 insertions, 6 deletions
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); } } }; |
