| ... | @@ -170,7 +170,10 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, data: []const []u8, of | ... | @@ -170,7 +170,10 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, data: []const []u8, of |
| 170 | } | 170 | } |
| 171 | | 171 | |
| 172 | pub async fn open( | 172 | pub async fn open( |
| 173 | loop: *event.Loop, path: []const u8, flags: u32, mode: os.File.Mode, | 173 | loop: *event.Loop, |
| | 174 | path: []const u8, |
| | 175 | flags: u32, |
| | 176 | mode: os.File.Mode, |
| 174 | ) os.File.OpenError!os.FileHandle { | 177 | ) os.File.OpenError!os.FileHandle { |
| 175 | // workaround for https://github.com/ziglang/zig/issues/1194 | 178 | // workaround for https://github.com/ziglang/zig/issues/1194 |
| 176 | suspend { | 179 | suspend { |
| ... | @@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type { | ... | @@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type { |
| 375 | os_data: OsData, | 378 | os_data: OsData, |
| 376 | | 379 | |
| 377 | const OsData = switch (builtin.os) { | 380 | const OsData = switch (builtin.os) { |
| 378 | builtin.Os.macosx => struct{ | 381 | builtin.Os.macosx => struct { |
| 379 | file_table: FileTable, | 382 | file_table: FileTable, |
| 380 | table_lock: event.Lock, | 383 | table_lock: event.Lock, |
| 381 | | 384 | |
| ... | @@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type { | ... | @@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type { |
| 477 | var close_op_consumed = false; | 480 | var close_op_consumed = false; |
| 478 | defer if (!close_op_consumed) close_op.finish(); | 481 | defer if (!close_op_consumed) close_op.finish(); |
| 479 | | 482 | |
| 480 | const flags = posix.O_SYMLINK|posix.O_EVTONLY; | 483 | const flags = posix.O_SYMLINK | posix.O_EVTONLY; |
| 481 | const mode = 0; | 484 | const mode = 0; |
| 482 | const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable); | 485 | const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable); |
| 483 | close_op.setHandle(fd); | 486 | close_op.setHandle(fd); |
| 484 | | 487 | |
| 485 | var put_data: *OsData.Put = undefined; | 488 | var put_data: *OsData.Put = undefined; |
| 486 | const putter = try async self.kqPutEvents(close_op, value, &put_data); | 489 | const putter = try async self.kqPutEvents(close_op, value, &put_data); |
| 487 | close_op_consumed = true; | 490 | close_op_consumed = true; |
| ... | @@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type { | ... | @@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type { |
| 549 | error.ProcessNotFound => unreachable, | 552 | error.ProcessNotFound => unreachable, |
| 550 | error.AccessDenied, error.SystemResources => { | 553 | error.AccessDenied, error.SystemResources => { |
| 551 | // TODO https://github.com/ziglang/zig/issues/769 | 554 | // TODO https://github.com/ziglang/zig/issues/769 |
| 552 | const casted_err = @errSetCast(error{AccessDenied,SystemResources}, err); | 555 | const casted_err = @errSetCast(error{ |
| | 556 | AccessDenied, |
| | 557 | SystemResources, |
| | 558 | }, err); |
| 553 | await (async self.channel.put(casted_err) catch unreachable); | 559 | await (async self.channel.put(casted_err) catch unreachable); |
| 554 | }, | 560 | }, |
| 555 | } | 561 | } |
| ... | @@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type { | ... | @@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type { |
| 667 | } | 673 | } |
| 668 | }; | 674 | }; |
| 669 | if (user_value) |v| { | 675 | if (user_value) |v| { |
| 670 | await (async channel.put(Self.Event{ .CloseWrite = v }) catch unreachable); | 676 | await (async channel.put(Event{ |
| | 677 | .id = WatchEventId.CloseWrite, |
| | 678 | .data = v, |
| | 679 | }) catch unreachable); |
| 671 | } | 680 | } |
| 672 | } | 681 | } |
| 673 | } | 682 | } |
| ... | @@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type { | ... | @@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type { |
| 691 | error.FileDescriptorIncompatibleWithEpoll => unreachable, | 700 | error.FileDescriptorIncompatibleWithEpoll => unreachable, |
| 692 | error.Unexpected => unreachable, | 701 | error.Unexpected => unreachable, |
| 693 | }; | 702 | }; |
| 694 | await (async channel.put(Self.Event{ .Err = transformed_err }) catch unreachable); | 703 | await (async channel.put(transformed_err) catch unreachable); |
| 695 | }; | 704 | }; |
| 696 | }, | 705 | }, |
| 697 | else => unreachable, | 706 | else => unreachable, |