aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fs
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-07-01 09:06:54 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-07-07 22:43:52 -0700
commit4bca5faca60df971712e538758315a0e0afe89a0 (patch)
treefe0b8bac0ec070c00b46706edc84ee4c7b997e37 /lib/std/fs
parentd6ac04c47811f162ca662f43d3c93a5dc0dcce86 (diff)
downloadzig-4bca5faca60df971712e538758315a0e0afe89a0.tar.gz
zig-4bca5faca60df971712e538758315a0e0afe89a0.zip
std.Build.Cache: write manifest without heap allocating
Now that the buffered writing interface is not generic.
Diffstat (limited to 'lib/std/fs')
-rw-r--r--lib/std/fs/File.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/std/fs/File.zig b/lib/std/fs/File.zig
index 2972c86722..8a761c2e98 100644
--- a/lib/std/fs/File.zig
+++ b/lib/std/fs/File.zig
@@ -1894,6 +1894,20 @@ pub const Writer = struct {
},
}
}
+
+ pub const EndError = SetEndPosError || std.io.Writer.Error;
+
+ /// Flushes any buffered data and sets the end position of the file.
+ ///
+ /// If not overwriting existing contents, then calling `interface.flush`
+ /// directly is sufficient.
+ ///
+ /// Flush failure is handled by setting `err` so that it can be handled
+ /// along with other write failures.
+ pub fn end(w: *Writer) EndError!void {
+ try w.interface.flush();
+ return w.file.setEndPos(w.pos);
+ }
};
/// Defaults to positional reading; falls back to streaming.