aboutsummaryrefslogtreecommitdiff
path: root/std/io.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-04-30 22:09:44 -0400
committerAndrew Kelley <superjoe30@gmail.com>2017-04-30 22:09:44 -0400
commitc5dd536845cffdf9f0c22de0a67a89d84d078e24 (patch)
tree3586c3f48a0a37bf8282769d75e420520327882b /std/io.zig
parent943dbe5b5098b243cea5e174cc2238f24d884253 (diff)
downloadzig-c5dd536845cffdf9f0c22de0a67a89d84d078e24.tar.gz
zig-c5dd536845cffdf9f0c22de0a67a89d84d078e24.zip
zig build: support install for zig artifacts
also make os.copyFile atomic closes #332
Diffstat (limited to 'std/io.zig')
-rw-r--r--std/io.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/std/io.zig b/std/io.zig
index 0bf34acaa4..e2d0f3bab9 100644
--- a/std/io.zig
+++ b/std/io.zig
@@ -67,16 +67,22 @@ pub const OutStream = struct {
buffer: [os.page_size]u8,
index: usize,
+ /// Calls ::openMode with 0o666 for the mode.
+ pub fn open(path: []const u8, allocator: ?&mem.Allocator) -> %OutStream {
+ return openMode(path, 0o666, allocator);
+
+ }
+
/// `path` may need to be copied in memory to add a null terminating byte. In this case
/// a fixed size buffer of size std.os.max_noalloc_path_len is an attempted solution. If the fixed
/// size buffer is too small, and the provided allocator is null, error.NameTooLong is returned.
/// otherwise if the fixed size buffer is too small, allocator is used to obtain the needed memory.
/// Call close to clean up.
- pub fn open(path: []const u8, allocator: ?&mem.Allocator) -> %OutStream {
+ pub fn openMode(path: []const u8, mode: usize, allocator: ?&mem.Allocator) -> %OutStream {
switch (@compileVar("os")) {
Os.linux, Os.darwin, Os.macosx, Os.ios => {
const flags = system.O_LARGEFILE|system.O_WRONLY|system.O_CREAT|system.O_CLOEXEC|system.O_TRUNC;
- const fd = %return os.posixOpen(path, flags, 0o666, allocator);
+ const fd = %return os.posixOpen(path, flags, mode, allocator);
return OutStream {
.fd = fd,
.index = 0,