diff options
| author | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-03-08 16:28:49 -0600 |
|---|---|---|
| committer | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-03-14 10:12:46 -0600 |
| commit | 3110060351f98ea8de65809379e1bcd9607fb1cb (patch) | |
| tree | 2405799765191031a7ca1b8f22cd495dc0b8642f /lib/std/fs | |
| parent | eb4d313dbc406b37f6bfdd98988c88c3b8ed542e (diff) | |
| download | zig-3110060351f98ea8de65809379e1bcd9607fb1cb.tar.gz zig-3110060351f98ea8de65809379e1bcd9607fb1cb.zip | |
Add `lock` to fs.File.OpenFlags
Diffstat (limited to 'lib/std/fs')
| -rw-r--r-- | lib/std/fs/file.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index c4991a81ff..e892fc3b8f 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -41,6 +41,15 @@ pub const File = struct { read: bool = true, write: bool = false, + /// Open the file with exclusive access. If `write` is true, then the file is opened with an + /// exclusive lock, meaning that no other processes can read or write to the file. Otherwise + /// the file is opened with a shared lock, allowing the other processes to read from the + /// file, but not to write to the file. + /// + /// Note that the lock is only advisory on Linux. This means that a process that does not + /// respect the locking API can still read and write to the file, despite the lock. + lock: bool = false, + /// This prevents `O_NONBLOCK` from being passed even if `std.io.is_async`. /// It allows the use of `noasync` when calling functions related to opening /// the file, reading, and writing. |
