diff options
| author | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-04-07 18:00:12 -0600 |
|---|---|---|
| committer | LeRoyce Pearson <leroycepearson@geemili.xyz> | 2020-04-07 18:00:12 -0600 |
| commit | 317f06dc7741dcb5579381fc4ad26dd23346eb67 (patch) | |
| tree | 02a713e7a809c81d01b39032ab35703d75ad6705 /lib/std/fs | |
| parent | 117d15ed7a230d065cf88faa8156c08f7160e08b (diff) | |
| download | zig-317f06dc7741dcb5579381fc4ad26dd23346eb67.tar.gz zig-317f06dc7741dcb5579381fc4ad26dd23346eb67.zip | |
Add lock_nonblocking flag for creating or opening files
Also, make windows share delete access. Rationale: this is how it works
on Unix systems, mostly because locks are (usually) advisory on Unix.
Diffstat (limited to 'lib/std/fs')
| -rw-r--r-- | lib/std/fs/file.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 32eb1460c4..2a6ad875c5 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -60,6 +60,11 @@ pub const File = struct { /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt lock: Lock = .None, + /// Sets whether or not to wait until the file is locked to return. If set to true, + /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file + /// is available to proceed. + lock_nonblocking: 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. @@ -94,6 +99,11 @@ pub const File = struct { /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt lock: Lock = .None, + /// Sets whether or not to wait until the file is locked to return. If set to true, + /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file + /// is available to proceed. + lock_nonblocking: bool = false, + /// For POSIX systems this is the file system mode the file will /// be created with. mode: Mode = default_mode, |
