@@ -78,8 +78,7 @@ pub async fn pwritev(loop: *Loop, fd: os.FileHandle, data: []const []const u8, o
78
78
builtin .Os .macosx ,
79
79
builtin .Os .linux ,
80
80
= > return await (async pwritevPosix (loop , fd , data , offset ) catch unreachable ),
81
- builtin .Os .windows ,
82
- = > return await (async pwritevWindows (loop , fd , data , offset ) catch unreachable ),
81
+ builtin .Os .windows = > return await (async pwritevWindows (loop , fd , data , offset ) catch unreachable ),
83
82
else = > @compileError ("Unsupported OS" ),
84
83
}
85
84
}
@@ -147,7 +146,6 @@ pub async fn pwriteWindows(loop: *Loop, fd: os.FileHandle, data: []const u8, off
147
146
}
148
147
}
149
148
150
-
151
149
/// data - just the inner references - must live until pwritev promise completes.
152
150
pub async fn pwritevPosix (loop : * Loop , fd : os.FileHandle , data : []const []const u8 , offset : usize ) ! void {
153
151
// workaround for https://github.com/ziglang/zig/issues/1194
@@ -203,8 +201,7 @@ pub async fn preadv(loop: *Loop, fd: os.FileHandle, data: []const []u8, offset:
203
201
builtin .Os .macosx ,
204
202
builtin .Os .linux ,
205
203
= > return await (async preadvPosix (loop , fd , data , offset ) catch unreachable ),
206
- builtin .Os .windows ,
207
- = > return await (async preadvWindows (loop , fd , data , offset ) catch unreachable ),
204
+ builtin .Os .windows = > return await (async preadvWindows (loop , fd , data , offset ) catch unreachable ),
208
205
else = > @compileError ("Unsupported OS" ),
209
206
}
210
207
}
@@ -222,7 +219,7 @@ pub async fn preadvWindows(loop: *Loop, fd: os.FileHandle, data: []const []u8, o
222
219
var inner_off : usize = 0 ;
223
220
while (true ) {
224
221
const v = data_copy [iov_i ];
225
- const amt_read = try await (async preadWindows (loop , fd , v [inner_off .. v .len - inner_off ], offset + off ) catch unreachable );
222
+ const amt_read = try await (async preadWindows (loop , fd , v [inner_off .. v .len - inner_off ], offset + off ) catch unreachable );
226
223
off += amt_read ;
227
224
inner_off += amt_read ;
228
225
if (inner_off == v .len ) {
@@ -340,16 +337,15 @@ pub async fn openPosix(
340
337
resume @handle ();
341
338
}
342
339
343
- const path_with_null = try std .cstr .addNullByte (loop .allocator , path );
344
- defer loop .allocator .free (path_with_null );
340
+ const path_c = try std .os .toPosixPath (path );
345
341
346
342
var req_node = RequestNode {
347
343
.prev = null ,
348
344
.next = null ,
349
345
.data = Request {
350
346
.msg = Request.Msg {
351
347
.Open = Request.Msg.Open {
352
- .path = path_with_null [0.. path .len ],
348
+ .path = path_c [0.. path .len ],
353
349
.flags = flags ,
354
350
.mode = mode ,
355
351
.result = undefined ,
@@ -408,8 +404,7 @@ pub async fn openWriteMode(loop: *Loop, path: []const u8, mode: os.File.Mode) os
408
404
const flags = posix .O_LARGEFILE | posix .O_WRONLY | posix .O_CREAT | posix .O_CLOEXEC | posix .O_TRUNC ;
409
405
return await (async openPosix (loop , path , flags , os .File .default_mode ) catch unreachable );
410
406
},
411
- builtin .Os .windows ,
412
- = > return os .windowsOpen (
407
+ builtin .Os .windows = > return os .windowsOpen (
413
408
path ,
414
409
windows .GENERIC_WRITE ,
415
410
windows .FILE_SHARE_WRITE | windows .FILE_SHARE_READ | windows .FILE_SHARE_DELETE ,
@@ -434,7 +429,7 @@ pub async fn openReadWrite(
434
429
435
430
builtin .Os .windows = > return os .windowsOpen (
436
431
path ,
437
- windows .GENERIC_WRITE | windows .GENERIC_READ ,
432
+ windows .GENERIC_WRITE | windows .GENERIC_READ ,
438
433
windows .FILE_SHARE_WRITE | windows .FILE_SHARE_READ | windows .FILE_SHARE_DELETE ,
439
434
windows .OPEN_ALWAYS ,
440
435
windows .FILE_ATTRIBUTE_NORMAL | windows .FILE_FLAG_OVERLAPPED ,
@@ -510,8 +505,7 @@ pub const CloseOperation = struct {
510
505
self .loop .allocator .destroy (self );
511
506
}
512
507
},
513
- builtin .Os .windows ,
514
- = > {
508
+ builtin .Os .windows = > {
515
509
if (self .os_data .handle ) | handle | {
516
510
os .close (handle );
517
511
}
@@ -529,8 +523,7 @@ pub const CloseOperation = struct {
529
523
self .os_data .close_req_node .data .msg .Close .fd = handle ;
530
524
self .os_data .have_fd = true ;
531
525
},
532
- builtin .Os .windows ,
533
- = > {
526
+ builtin .Os .windows = > {
534
527
self .os_data .handle = handle ;
535
528
},
536
529
else = > @compileError ("Unsupported OS" ),
@@ -545,8 +538,7 @@ pub const CloseOperation = struct {
545
538
= > {
546
539
self .os_data .have_fd = false ;
547
540
},
548
- builtin .Os .windows ,
549
- = > {
541
+ builtin .Os .windows = > {
550
542
self .os_data .handle = null ;
551
543
},
552
544
else = > @compileError ("Unsupported OS" ),
@@ -561,8 +553,7 @@ pub const CloseOperation = struct {
561
553
assert (self .os_data .have_fd );
562
554
return self .os_data .close_req_node .data .msg .Close .fd ;
563
555
},
564
- builtin .Os .windows ,
565
- = > {
556
+ builtin .Os .windows = > {
566
557
return self .os_data .handle .? ;
567
558
},
568
559
else = > @compileError ("Unsupported OS" ),
@@ -582,8 +573,7 @@ pub async fn writeFileMode(loop: *Loop, path: []const u8, contents: []const u8,
582
573
builtin .Os .linux ,
583
574
builtin .Os .macosx ,
584
575
= > return await (async writeFileModeThread (loop , path , contents , mode ) catch unreachable ),
585
- builtin .Os .windows ,
586
- = > return await (async writeFileWindows (loop , path , contents ) catch unreachable ),
576
+ builtin .Os .windows = > return await (async writeFileWindows (loop , path , contents ) catch unreachable ),
587
577
else = > @compileError ("Unsupported OS" ),
588
578
}
589
579
}
@@ -1000,7 +990,7 @@ pub fn Watch(comptime V: type) type {
1000
990
const basename_utf16le_null = try std .unicode .utf8ToUtf16LeWithNull (self .channel .loop .allocator , basename );
1001
991
var basename_utf16le_null_consumed = false ;
1002
992
defer if (! basename_utf16le_null_consumed ) self .channel .loop .allocator .free (basename_utf16le_null );
1003
- const basename_utf16le_no_null = basename_utf16le_null [0.. basename_utf16le_null .len - 1 ];
993
+ const basename_utf16le_no_null = basename_utf16le_null [0 .. basename_utf16le_null .len - 1 ];
1004
994
1005
995
const dir_handle = windows .CreateFileW (
1006
996
dirname_utf16le .ptr ,
@@ -1014,9 +1004,8 @@ pub fn Watch(comptime V: type) type {
1014
1004
if (dir_handle == windows .INVALID_HANDLE_VALUE ) {
1015
1005
const err = windows .GetLastError ();
1016
1006
switch (err ) {
1017
- windows .ERROR .FILE_NOT_FOUND ,
1018
- windows .ERROR .PATH_NOT_FOUND ,
1019
- = > return error .PathNotFound ,
1007
+ windows .ERROR .FILE_NOT_FOUND = > return error .FileNotFound ,
1008
+ windows .ERROR .PATH_NOT_FOUND = > return error .FileNotFound ,
1020
1009
else = > return os .unexpectedErrorWindows (err ),
1021
1010
}
1022
1011
}
@@ -1102,7 +1091,10 @@ pub fn Watch(comptime V: type) type {
1102
1091
1103
1092
// TODO handle this error not in the channel but in the setup
1104
1093
_ = os .windowsCreateIoCompletionPort (
1105
- dir_handle , self .channel .loop .os_data .io_port , completion_key , undefined ,
1094
+ dir_handle ,
1095
+ self .channel .loop .os_data .io_port ,
1096
+ completion_key ,
1097
+ undefined ,
1106
1098
) catch | err | {
1107
1099
await (async self .channel .put (err ) catch unreachable );
1108
1100
return ;
@@ -1122,10 +1114,10 @@ pub fn Watch(comptime V: type) type {
1122
1114
& event_buf ,
1123
1115
@intCast (windows .DWORD , event_buf .len ),
1124
1116
windows .FALSE , // watch subtree
1125
- windows .FILE_NOTIFY_CHANGE_FILE_NAME | windows .FILE_NOTIFY_CHANGE_DIR_NAME |
1126
- windows .FILE_NOTIFY_CHANGE_ATTRIBUTES | windows .FILE_NOTIFY_CHANGE_SIZE |
1127
- windows .FILE_NOTIFY_CHANGE_LAST_WRITE | windows .FILE_NOTIFY_CHANGE_LAST_ACCESS |
1128
- windows .FILE_NOTIFY_CHANGE_CREATION | windows .FILE_NOTIFY_CHANGE_SECURITY ,
1117
+ windows .FILE_NOTIFY_CHANGE_FILE_NAME | windows .FILE_NOTIFY_CHANGE_DIR_NAME |
1118
+ windows .FILE_NOTIFY_CHANGE_ATTRIBUTES | windows .FILE_NOTIFY_CHANGE_SIZE |
1119
+ windows .FILE_NOTIFY_CHANGE_LAST_WRITE | windows .FILE_NOTIFY_CHANGE_LAST_ACCESS |
1120
+ windows .FILE_NOTIFY_CHANGE_CREATION | windows .FILE_NOTIFY_CHANGE_SECURITY ,
1129
1121
null , // number of bytes transferred (unused for async)
1130
1122
& overlapped ,
1131
1123
null , // completion routine - unused because we use IOCP
@@ -1152,7 +1144,7 @@ pub fn Watch(comptime V: type) type {
1152
1144
else = > null ,
1153
1145
};
1154
1146
if (emit ) | id | {
1155
- const basename_utf16le = ([* ]u16 )(& ev .FileName )[0.. ev .FileNameLength / 2 ];
1147
+ const basename_utf16le = ([* ]u16 )(& ev .FileName )[0 .. ev .FileNameLength / 2 ];
1156
1148
const user_value = blk : {
1157
1149
const held = await (async dir .table_lock .acquire () catch unreachable );
1158
1150
defer held .release ();
0 commit comments