aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorr00ster <r00ster91@protonmail.com>2022-04-12 11:32:45 +0200
committerGitHub <noreply@github.com>2022-04-12 05:32:45 -0400
commit988afd51cd34649887f493b6ac9e05fcaa1f768d (patch)
treedb1bddd7890534f4eb23d53061aa9d970db7dc9c /lib/std
parentd2681d2537b630359657e117ed77cf12a15bb7df (diff)
downloadzig-988afd51cd34649887f493b6ac9e05fcaa1f768d.tar.gz
zig-988afd51cd34649887f493b6ac9e05fcaa1f768d.zip
Add `std.fs.File.sync` (#11410)
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/fs/file.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig
index 568c34e0ac..3ea8dd0285 100644
--- a/lib/std/fs/file.zig
+++ b/lib/std/fs/file.zig
@@ -200,6 +200,17 @@ pub const File = struct {
}
}
+ pub const SyncError = os.SyncError;
+
+ /// Blocks until all pending file contents and metadata modifications
+ /// for the file have been synchronized with the underlying filesystem.
+ ///
+ /// Note that this does not ensure that metadata for the
+ /// directory containing the file has also reached disk.
+ pub fn sync(self: File) SyncError!void {
+ return os.fsync(self.handle);
+ }
+
/// Test whether the file refers to a terminal.
/// See also `supportsAnsiEscapeCodes`.
pub fn isTty(self: File) bool {