authorgravatar for takeshi@tetrate.ioTakeshi Yoneda <takeshi@tetrate.io> 2021-08-13 21:54:18+09:00
committergravatar for takeshi@tetrate.ioTakeshi Yoneda <takeshi@tetrate.io> 2021-08-13 21:54:18+09:00
log68617c9fb05ad7e92315edb0dec7c5fad56b6265
tree6aecb01b6b5ed3a7673bba4e58136b66b3b5ceb6
parentca4898c0f3590832d7a2ef84e8f4906e89d7f34e

Add comment about compiletime check.

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>

1 files changed, 5 insertions(+), 1 deletions(-)

lib/std/fs.zig+5-1
...@@ -937,6 +937,8 @@ pub const Dir = struct {...@@ -937,6 +937,8 @@ pub const Dir = struct {
937 try os.openatZ(self.fd, sub_path, os_flags, 0);937 try os.openatZ(self.fd, sub_path, os_flags, 0);
938 errdefer os.close(fd);938 errdefer os.close(fd);
939939
940 // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block
941 // since it is not compiltime-known and we need to avoid undefined symbol in Wasm.
940 if (builtin.target.os.tag != .wasi) {942 if (builtin.target.os.tag != .wasi) {
941 if (!has_flock_open_flags and flags.lock != .None) {943 if (!has_flock_open_flags and flags.lock != .None) {
942 // TODO: integrate async I/O944 // TODO: integrate async I/O
...@@ -1089,8 +1091,10 @@ pub const Dir = struct {...@@ -1089,8 +1091,10 @@ pub const Dir = struct {
1089 try os.openatZ(self.fd, sub_path_c, os_flags, flags.mode);1091 try os.openatZ(self.fd, sub_path_c, os_flags, flags.mode);
1090 errdefer os.close(fd);1092 errdefer os.close(fd);
10911093
1094 // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block
1095 // since it is not compiltime-known and we need to avoid undefined symbol in Wasm.
1092 if (builtin.target.os.tag != .wasi) {1096 if (builtin.target.os.tag != .wasi) {
1093 if (!has_flock_open_flags and flags.lock != .None and builtin.target.os.tag != .wasi) {1097 if (!has_flock_open_flags and flags.lock != .None) {
1094 // TODO: integrate async I/O1098 // TODO: integrate async I/O
1095 const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);1099 const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK_NB else @as(i32, 0);
1096 try os.flock(fd, switch (flags.lock) {1100 try os.flock(fd, switch (flags.lock) {