authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-27 02:40:38+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-05-27 02:40:38+03:00
log8f5f8090c5a58c41bf0ae7cec282c0949f459d2f
treeddf8c6e5ed89fecb8448db30e0095045f45978f4
parent41502c6aa53a3da31b276c23c4db74db7d04796b
parentba35eeb417e4d54ce4c559871b9330bc95afc053
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #15803 from linusg/std-snek-case-enums

std: Snake-case some public facing enums

16 files changed, 266 insertions(+), 262 deletions(-)

lib/std/Build/Cache.zig+3-3
......@@ -408,7 +408,7 @@ pub const Manifest = struct {
408408 if (self.cache.manifest_dir.createFile(&manifest_file_path, .{
409409 .read = true,
410410 .truncate = false,
411 .lock = .Exclusive,
411 .lock = .exclusive,
412412 .lock_nonblocking = self.want_shared_lock,
413413 })) |manifest_file| {
414414 self.manifest_file = manifest_file;
......@@ -418,7 +418,7 @@ pub const Manifest = struct {
418418 error.WouldBlock => {
419419 self.manifest_file = try self.cache.manifest_dir.openFile(&manifest_file_path, .{
420420 .mode = .read_write,
421 .lock = .Shared,
421 .lock = .shared,
422422 });
423423 break;
424424 },
......@@ -885,7 +885,7 @@ pub const Manifest = struct {
885885 // Here we intentionally have a period where the lock is released, in case there are
886886 // other processes holding a shared lock.
887887 manifest_file.unlock();
888 try manifest_file.lock(.Exclusive);
888 try manifest_file.lock(.exclusive);
889889 }
890890 self.have_exclusive_lock = true;
891891 return true;
lib/std/Build/Step/InstallDir.zig+2-2
......@@ -80,8 +80,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
8080 const cwd = fs.cwd();
8181
8282 switch (entry.kind) {
83 .Directory => try cwd.makePath(dest_path),
84 .File => {
83 .directory => try cwd.makePath(dest_path),
84 .file => {
8585 for (self.options.blank_extensions) |ext| {
8686 if (mem.endsWith(u8, entry.path, ext)) {
8787 try dest_builder.truncateFile(dest_path);
lib/std/crypto/Certificate/Bundle.zig+1-1
......@@ -169,7 +169,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.IterableDir
169169 var it = iterable_dir.iterate();
170170 while (try it.next()) |entry| {
171171 switch (entry.kind) {
172 .File, .SymLink => {},
172 .file, .sym_link => {},
173173 else => continue,
174174 }
175175
lib/std/event/loop.zig+38-38
......@@ -62,9 +62,9 @@ pub const Loop = struct {
6262 pub const Overlapped = @TypeOf(overlapped_init);
6363
6464 pub const Id = enum {
65 Basic,
66 Stop,
67 EventFd,
65 basic,
66 stop,
67 event_fd,
6868 };
6969
7070 pub const EventFd = switch (builtin.os.tag) {
......@@ -165,11 +165,11 @@ pub const Loop = struct {
165165 .available_eventfd_resume_nodes = std.atomic.Stack(ResumeNode.EventFd).init(),
166166 .eventfd_resume_nodes = undefined,
167167 .final_resume_node = ResumeNode{
168 .id = ResumeNode.Id.Stop,
168 .id = .stop,
169169 .handle = undefined,
170170 .overlapped = ResumeNode.overlapped_init,
171171 },
172 .fs_end_request = .{ .data = .{ .msg = .end, .finish = .NoAction } },
172 .fs_end_request = .{ .data = .{ .msg = .end, .finish = .no_action } },
173173 .fs_queue = std.atomic.Queue(Request).init(),
174174 .fs_thread = undefined,
175175 .fs_thread_wakeup = .{},
......@@ -224,7 +224,7 @@ pub const Loop = struct {
224224 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
225225 .data = ResumeNode.EventFd{
226226 .base = ResumeNode{
227 .id = .EventFd,
227 .id = .event_fd,
228228 .handle = undefined,
229229 .overlapped = ResumeNode.overlapped_init,
230230 },
......@@ -282,7 +282,7 @@ pub const Loop = struct {
282282 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
283283 .data = ResumeNode.EventFd{
284284 .base = ResumeNode{
285 .id = ResumeNode.Id.EventFd,
285 .id = .event_fd,
286286 .handle = undefined,
287287 .overlapped = ResumeNode.overlapped_init,
288288 },
......@@ -347,7 +347,7 @@ pub const Loop = struct {
347347 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
348348 .data = ResumeNode.EventFd{
349349 .base = ResumeNode{
350 .id = ResumeNode.Id.EventFd,
350 .id = .event_fd,
351351 .handle = undefined,
352352 .overlapped = ResumeNode.overlapped_init,
353353 },
......@@ -413,7 +413,7 @@ pub const Loop = struct {
413413 eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{
414414 .data = ResumeNode.EventFd{
415415 .base = ResumeNode{
416 .id = ResumeNode.Id.EventFd,
416 .id = .event_fd,
417417 .handle = undefined,
418418 .overlapped = ResumeNode.overlapped_init,
419419 },
......@@ -503,7 +503,7 @@ pub const Loop = struct {
503503 assert(flags & os.linux.EPOLL.ONESHOT == os.linux.EPOLL.ONESHOT);
504504 var resume_node = ResumeNode.Basic{
505505 .base = ResumeNode{
506 .id = .Basic,
506 .id = .basic,
507507 .handle = @frame(),
508508 .overlapped = ResumeNode.overlapped_init,
509509 },
......@@ -590,7 +590,7 @@ pub const Loop = struct {
590590 pub fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, flags: u16) void {
591591 var resume_node = ResumeNode.Basic{
592592 .base = ResumeNode{
593 .id = ResumeNode.Id.Basic,
593 .id = .basic,
594594 .handle = @frame(),
595595 .overlapped = ResumeNode.overlapped_init,
596596 },
......@@ -1019,7 +1019,7 @@ pub const Loop = struct {
10191019 .result = undefined,
10201020 },
10211021 },
1022 .finish = .{ .TickNode = .{ .data = @frame() } },
1022 .finish = .{ .tick_node = .{ .data = @frame() } },
10231023 },
10241024 };
10251025 suspend {
......@@ -1041,7 +1041,7 @@ pub const Loop = struct {
10411041 .result = undefined,
10421042 },
10431043 },
1044 .finish = .{ .TickNode = .{ .data = @frame() } },
1044 .finish = .{ .tick_node = .{ .data = @frame() } },
10451045 },
10461046 };
10471047 suspend {
......@@ -1055,7 +1055,7 @@ pub const Loop = struct {
10551055 var req_node = Request.Node{
10561056 .data = .{
10571057 .msg = .{ .close = .{ .fd = fd } },
1058 .finish = .{ .TickNode = .{ .data = @frame() } },
1058 .finish = .{ .tick_node = .{ .data = @frame() } },
10591059 },
10601060 };
10611061 suspend {
......@@ -1076,7 +1076,7 @@ pub const Loop = struct {
10761076 .result = undefined,
10771077 },
10781078 },
1079 .finish = .{ .TickNode = .{ .data = @frame() } },
1079 .finish = .{ .tick_node = .{ .data = @frame() } },
10801080 },
10811081 };
10821082 suspend {
......@@ -1109,7 +1109,7 @@ pub const Loop = struct {
11091109 .result = undefined,
11101110 },
11111111 },
1112 .finish = .{ .TickNode = .{ .data = @frame() } },
1112 .finish = .{ .tick_node = .{ .data = @frame() } },
11131113 },
11141114 };
11151115 suspend {
......@@ -1143,7 +1143,7 @@ pub const Loop = struct {
11431143 .result = undefined,
11441144 },
11451145 },
1146 .finish = .{ .TickNode = .{ .data = @frame() } },
1146 .finish = .{ .tick_node = .{ .data = @frame() } },
11471147 },
11481148 };
11491149 suspend {
......@@ -1177,7 +1177,7 @@ pub const Loop = struct {
11771177 .result = undefined,
11781178 },
11791179 },
1180 .finish = .{ .TickNode = .{ .data = @frame() } },
1180 .finish = .{ .tick_node = .{ .data = @frame() } },
11811181 },
11821182 };
11831183 suspend {
......@@ -1210,7 +1210,7 @@ pub const Loop = struct {
12101210 .result = undefined,
12111211 },
12121212 },
1213 .finish = .{ .TickNode = .{ .data = @frame() } },
1213 .finish = .{ .tick_node = .{ .data = @frame() } },
12141214 },
12151215 };
12161216 suspend {
......@@ -1243,7 +1243,7 @@ pub const Loop = struct {
12431243 .result = undefined,
12441244 },
12451245 },
1246 .finish = .{ .TickNode = .{ .data = @frame() } },
1246 .finish = .{ .tick_node = .{ .data = @frame() } },
12471247 },
12481248 };
12491249 suspend {
......@@ -1277,7 +1277,7 @@ pub const Loop = struct {
12771277 .result = undefined,
12781278 },
12791279 },
1280 .finish = .{ .TickNode = .{ .data = @frame() } },
1280 .finish = .{ .tick_node = .{ .data = @frame() } },
12811281 },
12821282 };
12831283 suspend {
......@@ -1311,7 +1311,7 @@ pub const Loop = struct {
13111311 .result = undefined,
13121312 },
13131313 },
1314 .finish = .{ .TickNode = .{ .data = @frame() } },
1314 .finish = .{ .tick_node = .{ .data = @frame() } },
13151315 },
13161316 };
13171317 suspend {
......@@ -1391,7 +1391,7 @@ pub const Loop = struct {
13911391 .result = undefined,
13921392 },
13931393 },
1394 .finish = .{ .TickNode = .{ .data = @frame() } },
1394 .finish = .{ .tick_node = .{ .data = @frame() } },
13951395 },
13961396 };
13971397 suspend {
......@@ -1419,9 +1419,9 @@ pub const Loop = struct {
14191419 const handle = resume_node.handle;
14201420 const resume_node_id = resume_node.id;
14211421 switch (resume_node_id) {
1422 .Basic => {},
1423 .Stop => return,
1424 .EventFd => {
1422 .basic => {},
1423 .stop => return,
1424 .event_fd => {
14251425 const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node);
14261426 event_fd_node.epoll_op = os.linux.EPOLL.CTL_MOD;
14271427 const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node);
......@@ -1429,7 +1429,7 @@ pub const Loop = struct {
14291429 },
14301430 }
14311431 resume handle;
1432 if (resume_node_id == ResumeNode.Id.EventFd) {
1432 if (resume_node_id == .event_fd) {
14331433 self.finishOneEvent();
14341434 }
14351435 }
......@@ -1443,19 +1443,19 @@ pub const Loop = struct {
14431443 const handle = resume_node.handle;
14441444 const resume_node_id = resume_node.id;
14451445 switch (resume_node_id) {
1446 .Basic => {
1446 .basic => {
14471447 const basic_node = @fieldParentPtr(ResumeNode.Basic, "base", resume_node);
14481448 basic_node.kev = ev;
14491449 },
1450 .Stop => return,
1451 .EventFd => {
1450 .stop => return,
1451 .event_fd => {
14521452 const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node);
14531453 const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node);
14541454 self.available_eventfd_resume_nodes.push(stack_node);
14551455 },
14561456 }
14571457 resume handle;
1458 if (resume_node_id == ResumeNode.Id.EventFd) {
1458 if (resume_node_id == .event_fd) {
14591459 self.finishOneEvent();
14601460 }
14611461 }
......@@ -1477,9 +1477,9 @@ pub const Loop = struct {
14771477 const handle = resume_node.handle;
14781478 const resume_node_id = resume_node.id;
14791479 switch (resume_node_id) {
1480 .Basic => {},
1481 .Stop => return,
1482 .EventFd => {
1480 .basic => {},
1481 .stop => return,
1482 .event_fd => {
14831483 const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node);
14841484 const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node);
14851485 self.available_eventfd_resume_nodes.push(stack_node);
......@@ -1549,8 +1549,8 @@ pub const Loop = struct {
15491549 .close => |*msg| os.close(msg.fd),
15501550 }
15511551 switch (node.data.finish) {
1552 .TickNode => |*tick_node| self.onNextTick(tick_node),
1553 .NoAction => {},
1552 .tick_node => |*tick_node| self.onNextTick(tick_node),
1553 .no_action => {},
15541554 }
15551555 self.finishOneEvent();
15561556 }
......@@ -1586,8 +1586,8 @@ pub const Loop = struct {
15861586 pub const Node = std.atomic.Queue(Request).Node;
15871587
15881588 pub const Finish = union(enum) {
1589 TickNode: Loop.NextTickNode,
1590 NoAction,
1589 tick_node: Loop.NextTickNode,
1590 no_action,
15911591 };
15921592
15931593 pub const Msg = union(enum) {
lib/std/fmt.zig+18-18
......@@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt;
1414pub const default_max_depth = 3;
1515
1616pub const Alignment = enum {
17 Left,
18 Center,
19 Right,
17 left,
18 center,
19 right,
2020};
2121
2222pub const FormatOptions = struct {
2323 precision: ?usize = null,
2424 width: ?usize = null,
25 alignment: Alignment = .Right,
25 alignment: Alignment = .right,
2626 fill: u8 = ' ',
2727};
2828
......@@ -252,11 +252,11 @@ pub const Placeholder = struct {
252252 else => {},
253253 }
254254 break :init switch (ch) {
255 '<' => .Left,
256 '^' => .Center,
257 else => .Right,
255 '<' => .left,
256 '^' => .center,
257 else => .right,
258258 };
259 } else .Right;
259 } else .right;
260260
261261 // Parse the width parameter
262262 const width = comptime parser.specifier() catch |err|
......@@ -1034,18 +1034,18 @@ pub fn formatBuf(
10341034 return writer.writeAll(buf);
10351035
10361036 switch (options.alignment) {
1037 .Left => {
1037 .left => {
10381038 try writer.writeAll(buf);
10391039 try writer.writeByteNTimes(options.fill, padding);
10401040 },
1041 .Center => {
1041 .center => {
10421042 const left_padding = padding / 2;
10431043 const right_padding = (padding + 1) / 2;
10441044 try writer.writeByteNTimes(options.fill, left_padding);
10451045 try writer.writeAll(buf);
10461046 try writer.writeByteNTimes(options.fill, right_padding);
10471047 },
1048 .Right => {
1048 .right => {
10491049 try writer.writeByteNTimes(options.fill, padding);
10501050 try writer.writeAll(buf);
10511051 },
......@@ -1742,9 +1742,9 @@ pub fn Formatter(comptime format_fn: anytype) type {
17421742/// See also `parseUnsigned`.
17431743pub fn parseInt(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T {
17441744 if (buf.len == 0) return error.InvalidCharacter;
1745 if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .Pos);
1746 if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .Neg);
1747 return parseWithSign(T, buf, radix, .Pos);
1745 if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .pos);
1746 if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .neg);
1747 return parseWithSign(T, buf, radix, .pos);
17481748}
17491749
17501750test "parseInt" {
......@@ -1805,7 +1805,7 @@ fn parseWithSign(
18051805 comptime T: type,
18061806 buf: []const u8,
18071807 radix: u8,
1808 comptime sign: enum { Pos, Neg },
1808 comptime sign: enum { pos, neg },
18091809) ParseIntError!T {
18101810 if (buf.len == 0) return error.InvalidCharacter;
18111811
......@@ -1835,8 +1835,8 @@ fn parseWithSign(
18351835 }
18361836
18371837 const add = switch (sign) {
1838 .Pos => math.add,
1839 .Neg => math.sub,
1838 .pos => math.add,
1839 .neg => math.sub,
18401840 };
18411841
18421842 var x: T = 0;
......@@ -1866,7 +1866,7 @@ fn parseWithSign(
18661866/// Ignores '_' character in `buf`.
18671867/// See also `parseInt`.
18681868pub fn parseUnsigned(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T {
1869 return parseWithSign(T, buf, radix, .Pos);
1869 return parseWithSign(T, buf, radix, .pos);
18701870}
18711871
18721872test "parseUnsigned" {
lib/std/fs.zig+86-86
......@@ -385,16 +385,16 @@ pub const IterableDir = struct {
385385 continue :start_over;
386386 }
387387
388 const entry_kind = switch (darwin_entry.d_type) {
389 os.DT.BLK => Entry.Kind.BlockDevice,
390 os.DT.CHR => Entry.Kind.CharacterDevice,
391 os.DT.DIR => Entry.Kind.Directory,
392 os.DT.FIFO => Entry.Kind.NamedPipe,
393 os.DT.LNK => Entry.Kind.SymLink,
394 os.DT.REG => Entry.Kind.File,
395 os.DT.SOCK => Entry.Kind.UnixDomainSocket,
396 os.DT.WHT => Entry.Kind.Whiteout,
397 else => Entry.Kind.Unknown,
388 const entry_kind: Entry.Kind = switch (darwin_entry.d_type) {
389 os.DT.BLK => .block_device,
390 os.DT.CHR => .character_device,
391 os.DT.DIR => .directory,
392 os.DT.FIFO => .named_pipe,
393 os.DT.LNK => .sym_link,
394 os.DT.REG => .file,
395 os.DT.SOCK => .unix_domain_socket,
396 os.DT.WHT => .whiteout,
397 else => .unknown,
398398 };
399399 return Entry{
400400 .name = name,
......@@ -442,17 +442,17 @@ pub const IterableDir = struct {
442442 error.FileNotFound => unreachable, // lost the race
443443 else => |e| return e,
444444 };
445 const entry_kind = switch (stat_info.mode & os.S.IFMT) {
446 os.S.IFIFO => Entry.Kind.NamedPipe,
447 os.S.IFCHR => Entry.Kind.CharacterDevice,
448 os.S.IFDIR => Entry.Kind.Directory,
449 os.S.IFBLK => Entry.Kind.BlockDevice,
450 os.S.IFREG => Entry.Kind.File,
451 os.S.IFLNK => Entry.Kind.SymLink,
452 os.S.IFSOCK => Entry.Kind.UnixDomainSocket,
453 os.S.IFDOOR => Entry.Kind.Door,
454 os.S.IFPORT => Entry.Kind.EventPort,
455 else => Entry.Kind.Unknown,
445 const entry_kind: Entry.Kind = switch (stat_info.mode & os.S.IFMT) {
446 os.S.IFIFO => .named_pipe,
447 os.S.IFCHR => .character_device,
448 os.S.IFDIR => .directory,
449 os.S.IFBLK => .block_device,
450 os.S.IFREG => .file,
451 os.S.IFLNK => .sym_link,
452 os.S.IFSOCK => .unix_domain_socket,
453 os.S.IFDOOR => .door,
454 os.S.IFPORT => .event_port,
455 else => .unknown,
456456 };
457457 return Entry{
458458 .name = name,
......@@ -501,16 +501,16 @@ pub const IterableDir = struct {
501501 continue :start_over;
502502 }
503503
504 const entry_kind = switch (bsd_entry.d_type) {
505 os.DT.BLK => Entry.Kind.BlockDevice,
506 os.DT.CHR => Entry.Kind.CharacterDevice,
507 os.DT.DIR => Entry.Kind.Directory,
508 os.DT.FIFO => Entry.Kind.NamedPipe,
509 os.DT.LNK => Entry.Kind.SymLink,
510 os.DT.REG => Entry.Kind.File,
511 os.DT.SOCK => Entry.Kind.UnixDomainSocket,
512 os.DT.WHT => Entry.Kind.Whiteout,
513 else => Entry.Kind.Unknown,
504 const entry_kind: Entry.Kind = switch (bsd_entry.d_type) {
505 os.DT.BLK => .block_device,
506 os.DT.CHR => .character_device,
507 os.DT.DIR => .directory,
508 os.DT.FIFO => .named_pipe,
509 os.DT.LNK => .sym_link,
510 os.DT.REG => .file,
511 os.DT.SOCK => .unix_domain_socket,
512 os.DT.WHT => .whiteout,
513 else => .unknown,
514514 };
515515 return Entry{
516516 .name = name,
......@@ -595,14 +595,14 @@ pub const IterableDir = struct {
595595 }
596596 const statmode = stat_info.mode & os.S.IFMT;
597597
598 const entry_kind = switch (statmode) {
599 os.S.IFDIR => Entry.Kind.Directory,
600 os.S.IFBLK => Entry.Kind.BlockDevice,
601 os.S.IFCHR => Entry.Kind.CharacterDevice,
602 os.S.IFLNK => Entry.Kind.SymLink,
603 os.S.IFREG => Entry.Kind.File,
604 os.S.IFIFO => Entry.Kind.NamedPipe,
605 else => Entry.Kind.Unknown,
598 const entry_kind: Entry.Kind = switch (statmode) {
599 os.S.IFDIR => .directory,
600 os.S.IFBLK => .block_device,
601 os.S.IFCHR => .character_device,
602 os.S.IFLNK => .sym_link,
603 os.S.IFREG => .file,
604 os.S.IFIFO => .named_pipe,
605 else => .unknown,
606606 };
607607
608608 return Entry{
......@@ -679,15 +679,15 @@ pub const IterableDir = struct {
679679 continue :start_over;
680680 }
681681
682 const entry_kind = switch (linux_entry.d_type) {
683 linux.DT.BLK => Entry.Kind.BlockDevice,
684 linux.DT.CHR => Entry.Kind.CharacterDevice,
685 linux.DT.DIR => Entry.Kind.Directory,
686 linux.DT.FIFO => Entry.Kind.NamedPipe,
687 linux.DT.LNK => Entry.Kind.SymLink,
688 linux.DT.REG => Entry.Kind.File,
689 linux.DT.SOCK => Entry.Kind.UnixDomainSocket,
690 else => Entry.Kind.Unknown,
682 const entry_kind: Entry.Kind = switch (linux_entry.d_type) {
683 linux.DT.BLK => .block_device,
684 linux.DT.CHR => .character_device,
685 linux.DT.DIR => .directory,
686 linux.DT.FIFO => .named_pipe,
687 linux.DT.LNK => .sym_link,
688 linux.DT.REG => .file,
689 linux.DT.SOCK => .unix_domain_socket,
690 else => .unknown,
691691 };
692692 return Entry{
693693 .name = name,
......@@ -761,11 +761,11 @@ pub const IterableDir = struct {
761761 // Trust that Windows gives us valid UTF-16LE
762762 const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
763763 const name_utf8 = self.name_data[0..name_utf8_len];
764 const kind = blk: {
764 const kind: Entry.Kind = blk: {
765765 const attrs = dir_info.FileAttributes;
766 if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.Directory;
767 if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk Entry.Kind.SymLink;
768 break :blk Entry.Kind.File;
766 if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk .directory;
767 if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk .sym_link;
768 break :blk .file;
769769 };
770770 return Entry{
771771 .name = name_utf8,
......@@ -850,14 +850,14 @@ pub const IterableDir = struct {
850850 continue :start_over;
851851 }
852852
853 const entry_kind = switch (entry.d_type) {
854 .BLOCK_DEVICE => Entry.Kind.BlockDevice,
855 .CHARACTER_DEVICE => Entry.Kind.CharacterDevice,
856 .DIRECTORY => Entry.Kind.Directory,
857 .SYMBOLIC_LINK => Entry.Kind.SymLink,
858 .REGULAR_FILE => Entry.Kind.File,
859 .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,
860 else => Entry.Kind.Unknown,
853 const entry_kind: Entry.Kind = switch (entry.d_type) {
854 .BLOCK_DEVICE => .block_device,
855 .CHARACTER_DEVICE => .character_device,
856 .DIRECTORY => .directory,
857 .SYMBOLIC_LINK => .sym_link,
858 .REGULAR_FILE => .file,
859 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
860 else => .unknown,
861861 };
862862 return Entry{
863863 .name = name,
......@@ -964,7 +964,7 @@ pub const IterableDir = struct {
964964 dirname_len += 1;
965965 }
966966 try self.name_buffer.appendSlice(base.name);
967 if (base.kind == .Directory) {
967 if (base.kind == .directory) {
968968 var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) {
969969 error.NameTooLong => unreachable, // no path sep in base.name
970970 else => |e| return e,
......@@ -1157,9 +1157,9 @@ pub const Dir = struct {
11571157 else
11581158 0;
11591159 os_flags |= switch (flags.lock) {
1160 .None => @as(u32, 0),
1161 .Shared => os.O.SHLOCK | nonblocking_lock_flag,
1162 .Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
1160 .none => @as(u32, 0),
1161 .shared => os.O.SHLOCK | nonblocking_lock_flag,
1162 .exclusive => os.O.EXLOCK | nonblocking_lock_flag,
11631163 };
11641164 }
11651165 if (@hasDecl(os.O, "LARGEFILE")) {
......@@ -1182,13 +1182,13 @@ pub const Dir = struct {
11821182 // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block
11831183 // since it is not compiltime-known and we need to avoid undefined symbol in Wasm.
11841184 if (builtin.target.os.tag != .wasi) {
1185 if (!has_flock_open_flags and flags.lock != .None) {
1185 if (!has_flock_open_flags and flags.lock != .none) {
11861186 // TODO: integrate async I/O
11871187 const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
11881188 try os.flock(fd, switch (flags.lock) {
1189 .None => unreachable,
1190 .Shared => os.LOCK.SH | lock_nonblocking,
1191 .Exclusive => os.LOCK.EX | lock_nonblocking,
1189 .none => unreachable,
1190 .shared => os.LOCK.SH | lock_nonblocking,
1191 .exclusive => os.LOCK.EX | lock_nonblocking,
11921192 });
11931193 }
11941194 }
......@@ -1241,9 +1241,9 @@ pub const Dir = struct {
12411241 const range_off: w.LARGE_INTEGER = 0;
12421242 const range_len: w.LARGE_INTEGER = 1;
12431243 const exclusive = switch (flags.lock) {
1244 .None => return file,
1245 .Shared => false,
1246 .Exclusive => true,
1244 .none => return file,
1245 .shared => false,
1246 .exclusive => true,
12471247 };
12481248 try w.LockFile(
12491249 file.handle,
......@@ -1320,9 +1320,9 @@ pub const Dir = struct {
13201320 else
13211321 0;
13221322 const lock_flag: u32 = if (has_flock_open_flags) switch (flags.lock) {
1323 .None => @as(u32, 0),
1324 .Shared => os.O.SHLOCK | nonblocking_lock_flag,
1325 .Exclusive => os.O.EXLOCK | nonblocking_lock_flag,
1323 .none => @as(u32, 0),
1324 .shared => os.O.SHLOCK | nonblocking_lock_flag,
1325 .exclusive => os.O.EXLOCK | nonblocking_lock_flag,
13261326 } else 0;
13271327
13281328 const O_LARGEFILE = if (@hasDecl(os.O, "LARGEFILE")) os.O.LARGEFILE else 0;
......@@ -1339,13 +1339,13 @@ pub const Dir = struct {
13391339 // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block
13401340 // since it is not compiltime-known and we need to avoid undefined symbol in Wasm.
13411341 if (builtin.target.os.tag != .wasi) {
1342 if (!has_flock_open_flags and flags.lock != .None) {
1342 if (!has_flock_open_flags and flags.lock != .none) {
13431343 // TODO: integrate async I/O
13441344 const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0);
13451345 try os.flock(fd, switch (flags.lock) {
1346 .None => unreachable,
1347 .Shared => os.LOCK.SH | lock_nonblocking,
1348 .Exclusive => os.LOCK.EX | lock_nonblocking,
1346 .none => unreachable,
1347 .shared => os.LOCK.SH | lock_nonblocking,
1348 .exclusive => os.LOCK.EX | lock_nonblocking,
13491349 });
13501350 }
13511351 }
......@@ -1402,9 +1402,9 @@ pub const Dir = struct {
14021402 const range_off: w.LARGE_INTEGER = 0;
14031403 const range_len: w.LARGE_INTEGER = 1;
14041404 const exclusive = switch (flags.lock) {
1405 .None => return file,
1406 .Shared => false,
1407 .Exclusive => true,
1405 .none => return file,
1406 .shared => false,
1407 .exclusive => true,
14081408 };
14091409 try w.LockFile(
14101410 file.handle,
......@@ -2106,7 +2106,7 @@ pub const Dir = struct {
21062106 /// this function recursively removes its entries and then tries again.
21072107 /// This operation is not atomic on most file systems.
21082108 pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2109 var initial_iterable_dir = (try self.deleteTreeOpenInitialSubpath(sub_path, .File)) orelse return;
2109 var initial_iterable_dir = (try self.deleteTreeOpenInitialSubpath(sub_path, .file)) orelse return;
21102110
21112111 const StackItem = struct {
21122112 name: []const u8,
......@@ -2130,7 +2130,7 @@ pub const Dir = struct {
21302130 process_stack: while (stack.len != 0) {
21312131 var top = &(stack.slice()[stack.len - 1]);
21322132 while (try top.iter.next()) |entry| {
2133 var treat_as_dir = entry.kind == .Directory;
2133 var treat_as_dir = entry.kind == .directory;
21342134 handle_entry: while (true) {
21352135 if (treat_as_dir) {
21362136 if (stack.ensureUnusedCapacity(1)) {
......@@ -2291,7 +2291,7 @@ pub const Dir = struct {
22912291 /// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size.
22922292 /// This is slower than `deleteTree` but uses less stack space.
22932293 pub fn deleteTreeMinStackSize(self: Dir, sub_path: []const u8) DeleteTreeError!void {
2294 return self.deleteTreeMinStackSizeWithKindHint(sub_path, .File);
2294 return self.deleteTreeMinStackSizeWithKindHint(sub_path, .file);
22952295 }
22962296
22972297 fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void {
......@@ -2316,7 +2316,7 @@ pub const Dir = struct {
23162316 scan_dir: while (true) {
23172317 var dir_it = iterable_dir.iterateAssumeFirstIteration();
23182318 dir_it: while (try dir_it.next()) |entry| {
2319 var treat_as_dir = entry.kind == .Directory;
2319 var treat_as_dir = entry.kind == .directory;
23202320 handle_entry: while (true) {
23212321 if (treat_as_dir) {
23222322 const new_dir = iterable_dir.dir.openIterableDir(entry.name, .{ .no_follow = true }) catch |err| switch (err) {
......@@ -2407,7 +2407,7 @@ pub const Dir = struct {
24072407 fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File.Kind) !?IterableDir {
24082408 return iterable_dir: {
24092409 // Treat as a file by default
2410 var treat_as_dir = kind_hint == .Directory;
2410 var treat_as_dir = kind_hint == .directory;
24112411
24122412 handle_entry: while (true) {
24132413 if (treat_as_dir) {
lib/std/fs/file.zig+79-75
......@@ -35,17 +35,17 @@ pub const File = struct {
3535 pub const Gid = os.gid_t;
3636
3737 pub const Kind = enum {
38 BlockDevice,
39 CharacterDevice,
40 Directory,
41 NamedPipe,
42 SymLink,
43 File,
44 UnixDomainSocket,
45 Whiteout,
46 Door,
47 EventPort,
48 Unknown,
38 block_device,
39 character_device,
40 directory,
41 named_pipe,
42 sym_link,
43 file,
44 unix_domain_socket,
45 whiteout,
46 door,
47 event_port,
48 unknown,
4949 };
5050
5151 /// This is the default mode given to POSIX operating systems for creating
......@@ -81,7 +81,11 @@ pub const File = struct {
8181 read_write,
8282 };
8383
84 pub const Lock = enum { None, Shared, Exclusive };
84 pub const Lock = enum {
85 none,
86 shared,
87 exclusive,
88 };
8589
8690 pub const OpenFlags = struct {
8791 mode: OpenMode = .read_only,
......@@ -110,7 +114,7 @@ pub const File = struct {
110114 /// * Windows
111115 ///
112116 /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt
113 lock: Lock = .None,
117 lock: Lock = .none,
114118
115119 /// Sets whether or not to wait until the file is locked to return. If set to true,
116120 /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
......@@ -174,7 +178,7 @@ pub const File = struct {
174178 /// * Windows
175179 ///
176180 /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt
177 lock: Lock = .None,
181 lock: Lock = .none,
178182
179183 /// Sets whether or not to wait until the file is locked to return. If set to true,
180184 /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
......@@ -329,32 +333,32 @@ pub const File = struct {
329333 const mtime = st.mtime();
330334 const ctime = st.ctime();
331335 const kind: Kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) {
332 .BLOCK_DEVICE => Kind.BlockDevice,
333 .CHARACTER_DEVICE => Kind.CharacterDevice,
334 .DIRECTORY => Kind.Directory,
335 .SYMBOLIC_LINK => Kind.SymLink,
336 .REGULAR_FILE => Kind.File,
337 .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,
338 else => Kind.Unknown,
336 .BLOCK_DEVICE => .block_device,
337 .CHARACTER_DEVICE => .character_device,
338 .DIRECTORY => .directory,
339 .SYMBOLIC_LINK => .sym_link,
340 .REGULAR_FILE => .file,
341 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
342 else => .unknown,
339343 } else blk: {
340344 const m = st.mode & os.S.IFMT;
341345 switch (m) {
342 os.S.IFBLK => break :blk Kind.BlockDevice,
343 os.S.IFCHR => break :blk Kind.CharacterDevice,
344 os.S.IFDIR => break :blk Kind.Directory,
345 os.S.IFIFO => break :blk Kind.NamedPipe,
346 os.S.IFLNK => break :blk Kind.SymLink,
347 os.S.IFREG => break :blk Kind.File,
348 os.S.IFSOCK => break :blk Kind.UnixDomainSocket,
346 os.S.IFBLK => break :blk .block_device,
347 os.S.IFCHR => break :blk .character_device,
348 os.S.IFDIR => break :blk .directory,
349 os.S.IFIFO => break :blk .named_pipe,
350 os.S.IFLNK => break :blk .sym_link,
351 os.S.IFREG => break :blk .file,
352 os.S.IFSOCK => break :blk .unix_domain_socket,
349353 else => {},
350354 }
351355 if (builtin.os.tag == .solaris) switch (m) {
352 os.S.IFDOOR => break :blk Kind.Door,
353 os.S.IFPORT => break :blk Kind.EventPort,
356 os.S.IFDOOR => break :blk .door,
357 os.S.IFPORT => break :blk .event_port,
354358 else => {},
355359 };
356360
357 break :blk .Unknown;
361 break :blk .unknown;
358362 };
359363
360364 return Stat{
......@@ -391,7 +395,7 @@ pub const File = struct {
391395 .inode = info.InternalInformation.IndexNumber,
392396 .size = @bitCast(u64, info.StandardInformation.EndOfFile),
393397 .mode = 0,
394 .kind = if (info.StandardInformation.Directory == 0) .File else .Directory,
398 .kind = if (info.StandardInformation.Directory == 0) .file else .directory,
395399 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
396400 .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),
397401 .ctime = windows.fromSysTime(info.BasicInformation.CreationTime),
......@@ -609,7 +613,7 @@ pub const File = struct {
609613 }
610614
611615 /// Returns the `Kind` of file.
612 /// On Windows, can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown`
616 /// On Windows, can only return: `.file`, `.directory`, `.sym_link` or `.unknown`
613617 pub fn kind(self: Self) Kind {
614618 return self.inner.kind();
615619 }
......@@ -652,35 +656,35 @@ pub const File = struct {
652656 /// Returns the `Kind` of the file
653657 pub fn kind(self: Self) Kind {
654658 if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) {
655 .BLOCK_DEVICE => Kind.BlockDevice,
656 .CHARACTER_DEVICE => Kind.CharacterDevice,
657 .DIRECTORY => Kind.Directory,
658 .SYMBOLIC_LINK => Kind.SymLink,
659 .REGULAR_FILE => Kind.File,
660 .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,
661 else => Kind.Unknown,
659 .BLOCK_DEVICE => .block_device,
660 .CHARACTER_DEVICE => .character_device,
661 .DIRECTORY => .directory,
662 .SYMBOLIC_LINK => .sym_link,
663 .REGULAR_FILE => .file,
664 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
665 else => .unknown,
662666 };
663667
664668 const m = self.stat.mode & os.S.IFMT;
665669
666670 switch (m) {
667 os.S.IFBLK => return Kind.BlockDevice,
668 os.S.IFCHR => return Kind.CharacterDevice,
669 os.S.IFDIR => return Kind.Directory,
670 os.S.IFIFO => return Kind.NamedPipe,
671 os.S.IFLNK => return Kind.SymLink,
672 os.S.IFREG => return Kind.File,
673 os.S.IFSOCK => return Kind.UnixDomainSocket,
671 os.S.IFBLK => return .block_device,
672 os.S.IFCHR => return .character_device,
673 os.S.IFDIR => return .directory,
674 os.S.IFIFO => return .named_pipe,
675 os.S.IFLNK => return .sym_link,
676 os.S.IFREG => return .file,
677 os.S.IFSOCK => return .unix_domain_socket,
674678 else => {},
675679 }
676680
677681 if (builtin.os.tag == .solaris) switch (m) {
678 os.S.IFDOOR => return Kind.Door,
679 os.S.IFPORT => return Kind.EventPort,
682 os.S.IFDOOR => return .door,
683 os.S.IFPORT => return .event_port,
680684 else => {},
681685 };
682686
683 return .Unknown;
687 return .unknown;
684688 }
685689
686690 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
......@@ -738,17 +742,17 @@ pub const File = struct {
738742 const m = self.statx.mode & os.S.IFMT;
739743
740744 switch (m) {
741 os.S.IFBLK => return Kind.BlockDevice,
742 os.S.IFCHR => return Kind.CharacterDevice,
743 os.S.IFDIR => return Kind.Directory,
744 os.S.IFIFO => return Kind.NamedPipe,
745 os.S.IFLNK => return Kind.SymLink,
746 os.S.IFREG => return Kind.File,
747 os.S.IFSOCK => return Kind.UnixDomainSocket,
745 os.S.IFBLK => return .block_device,
746 os.S.IFCHR => return .character_device,
747 os.S.IFDIR => return .directory,
748 os.S.IFIFO => return .named_pipe,
749 os.S.IFLNK => return .sym_link,
750 os.S.IFREG => return .file,
751 os.S.IFSOCK => return .unix_domain_socket,
748752 else => {},
749753 }
750754
751 return .Unknown;
755 return .unknown;
752756 }
753757
754758 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
......@@ -790,18 +794,18 @@ pub const File = struct {
790794 }
791795
792796 /// Returns the `Kind` of the file.
793 /// Can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown`
797 /// Can only return: `.file`, `.directory`, `.sym_link` or `.unknown`
794798 pub fn kind(self: Self) Kind {
795799 if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) {
796800 if (self.reparse_tag & 0x20000000 != 0) {
797 return .SymLink;
801 return .sym_link;
798802 }
799803 } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) {
800 return .Directory;
804 return .directory;
801805 } else {
802 return .File;
806 return .file;
803807 }
804 return .Unknown;
808 return .unknown;
805809 }
806810
807811 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
......@@ -1465,9 +1469,9 @@ pub const File = struct {
14651469 if (is_windows) {
14661470 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
14671471 const exclusive = switch (l) {
1468 .None => return,
1469 .Shared => false,
1470 .Exclusive => true,
1472 .none => return,
1473 .shared => false,
1474 .exclusive => true,
14711475 };
14721476 return windows.LockFile(
14731477 file.handle,
......@@ -1486,9 +1490,9 @@ pub const File = struct {
14861490 };
14871491 } else {
14881492 return os.flock(file.handle, switch (l) {
1489 .None => os.LOCK.UN,
1490 .Shared => os.LOCK.SH,
1491 .Exclusive => os.LOCK.EX,
1493 .none => os.LOCK.UN,
1494 .shared => os.LOCK.SH,
1495 .exclusive => os.LOCK.EX,
14921496 }) catch |err| switch (err) {
14931497 error.WouldBlock => unreachable, // non-blocking=false
14941498 else => |e| return e,
......@@ -1532,9 +1536,9 @@ pub const File = struct {
15321536 if (is_windows) {
15331537 var io_status_block: windows.IO_STATUS_BLOCK = undefined;
15341538 const exclusive = switch (l) {
1535 .None => return,
1536 .Shared => false,
1537 .Exclusive => true,
1539 .none => return,
1540 .shared => false,
1541 .exclusive => true,
15381542 };
15391543 windows.LockFile(
15401544 file.handle,
......@@ -1553,9 +1557,9 @@ pub const File = struct {
15531557 };
15541558 } else {
15551559 os.flock(file.handle, switch (l) {
1556 .None => os.LOCK.UN,
1557 .Shared => os.LOCK.SH | os.LOCK.NB,
1558 .Exclusive => os.LOCK.EX | os.LOCK.NB,
1560 .none => os.LOCK.UN,
1561 .shared => os.LOCK.SH | os.LOCK.NB,
1562 .exclusive => os.LOCK.EX | os.LOCK.NB,
15591563 }) catch |err| switch (err) {
15601564 error.WouldBlock => return false,
15611565 else => |e| return e,
lib/std/fs/test.zig+21-21
......@@ -179,8 +179,8 @@ test "Dir.Iterator" {
179179 }
180180
181181 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
182 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));
183 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));
182 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
183 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
184184}
185185
186186test "Dir.Iterator many entries" {
......@@ -214,7 +214,7 @@ test "Dir.Iterator many entries" {
214214 i = 0;
215215 while (i < num) : (i += 1) {
216216 const name = try std.fmt.bufPrint(&buf, "{}", .{i});
217 try testing.expect(contains(&entries, .{ .name = name, .kind = .File }));
217 try testing.expect(contains(&entries, .{ .name = name, .kind = .file }));
218218 }
219219}
220220
......@@ -246,8 +246,8 @@ test "Dir.Iterator twice" {
246246 }
247247
248248 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
249 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));
250 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));
249 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
250 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
251251 }
252252}
253253
......@@ -280,8 +280,8 @@ test "Dir.Iterator reset" {
280280 }
281281
282282 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
283 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));
284 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));
283 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
284 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
285285
286286 iter.reset();
287287 }
......@@ -336,7 +336,7 @@ test "Dir.realpath smoke test" {
336336 var tmp_dir = tmpDir(.{});
337337 defer tmp_dir.cleanup();
338338
339 var file = try tmp_dir.dir.createFile("test_file", .{ .lock = File.Lock.Shared });
339 var file = try tmp_dir.dir.createFile("test_file", .{ .lock = .shared });
340340 // We need to close the file immediately as otherwise on Windows we'll end up
341341 // with a sharing violation.
342342 file.close();
......@@ -428,7 +428,7 @@ test "directory operations on files" {
428428 // ensure the file still exists and is a file as a sanity check
429429 file = try tmp_dir.dir.openFile(test_file_name, .{});
430430 const stat = try file.stat();
431 try testing.expect(stat.kind == .File);
431 try testing.expect(stat.kind == .file);
432432 file.close();
433433}
434434
......@@ -664,7 +664,7 @@ test "renameAbsolute" {
664664 try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(test_file_name, .{}));
665665 file = try tmp_dir.dir.openFile(renamed_test_file_name, .{});
666666 const stat = try file.stat();
667 try testing.expect(stat.kind == .File);
667 try testing.expect(stat.kind == .file);
668668 file.close();
669669
670670 // Renaming directories
......@@ -1035,10 +1035,10 @@ test "open file with exclusive nonblocking lock twice" {
10351035 var tmp = tmpDir(.{});
10361036 defer tmp.cleanup();
10371037
1038 const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true });
1038 const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true });
10391039 defer file1.close();
10401040
1041 const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true });
1041 const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true });
10421042 try testing.expectError(error.WouldBlock, file2);
10431043}
10441044
......@@ -1050,10 +1050,10 @@ test "open file with shared and exclusive nonblocking lock" {
10501050 var tmp = tmpDir(.{});
10511051 defer tmp.cleanup();
10521052
1053 const file1 = try tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true });
1053 const file1 = try tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true });
10541054 defer file1.close();
10551055
1056 const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true });
1056 const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true });
10571057 try testing.expectError(error.WouldBlock, file2);
10581058}
10591059
......@@ -1065,10 +1065,10 @@ test "open file with exclusive and shared nonblocking lock" {
10651065 var tmp = tmpDir(.{});
10661066 defer tmp.cleanup();
10671067
1068 const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true });
1068 const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true });
10691069 defer file1.close();
10701070
1071 const file2 = tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true });
1071 const file2 = tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true });
10721072 try testing.expectError(error.WouldBlock, file2);
10731073}
10741074
......@@ -1085,13 +1085,13 @@ test "open file with exclusive lock twice, make sure second lock waits" {
10851085 var tmp = tmpDir(.{});
10861086 defer tmp.cleanup();
10871087
1088 const file = try tmp.dir.createFile(filename, .{ .lock = .Exclusive });
1088 const file = try tmp.dir.createFile(filename, .{ .lock = .exclusive });
10891089 errdefer file.close();
10901090
10911091 const S = struct {
10921092 fn checkFn(dir: *fs.Dir, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void {
10931093 started.set();
1094 const file1 = try dir.createFile(filename, .{ .lock = .Exclusive });
1094 const file1 = try dir.createFile(filename, .{ .lock = .exclusive });
10951095
10961096 locked.set();
10971097 file1.close();
......@@ -1138,12 +1138,12 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" {
11381138 defer gpa.free(filename);
11391139
11401140 const file1 = try fs.createFileAbsolute(filename, .{
1141 .lock = .Exclusive,
1141 .lock = .exclusive,
11421142 .lock_nonblocking = true,
11431143 });
11441144
11451145 const file2 = fs.createFileAbsolute(filename, .{
1146 .lock = .Exclusive,
1146 .lock = .exclusive,
11471147 .lock_nonblocking = true,
11481148 });
11491149 file1.close();
......@@ -1348,7 +1348,7 @@ test "File.Metadata" {
13481348 defer file.close();
13491349
13501350 const metadata = try file.metadata();
1351 try testing.expect(metadata.kind() == .File);
1351 try testing.expect(metadata.kind() == .file);
13521352 try testing.expect(metadata.size() == 0);
13531353 _ = metadata.accessed();
13541354 _ = metadata.modified();
src/Module.zig+4-4
......@@ -3618,7 +3618,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
36183618 file.sub_file_path, want_local_cache, &digest,
36193619 });
36203620
3621 break :lock .Shared;
3621 break :lock .shared;
36223622 },
36233623 .parse_failure, .astgen_failure, .success_zir => lock: {
36243624 const unchanged_metadata =
......@@ -3633,7 +3633,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
36333633
36343634 log.debug("metadata changed: {s}", .{file.sub_file_path});
36353635
3636 break :lock .Exclusive;
3636 break :lock .exclusive;
36373637 },
36383638 };
36393639
......@@ -3715,11 +3715,11 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
37153715 }
37163716
37173717 // If we already have the exclusive lock then it is our job to update.
3718 if (builtin.os.tag == .wasi or lock == .Exclusive) break;
3718 if (builtin.os.tag == .wasi or lock == .exclusive) break;
37193719 // Otherwise, unlock to give someone a chance to get the exclusive lock
37203720 // and then upgrade to an exclusive lock.
37213721 cache_file.unlock();
3722 lock = .Exclusive;
3722 lock = .exclusive;
37233723 try cache_file.lock(lock);
37243724 }
37253725
src/Package.zig+2-2
......@@ -651,8 +651,8 @@ fn computePackageHash(
651651
652652 while (try walker.next()) |entry| {
653653 switch (entry.kind) {
654 .Directory => continue,
655 .File => {},
654 .directory => continue,
655 .file => {},
656656 else => return error.IllegalFileTypeInPackage,
657657 }
658658 const hashed_file = try arena.create(HashedFile);
src/main.zig+3-3
......@@ -4830,11 +4830,11 @@ fn fmtPathDir(
48304830
48314831 var dir_it = iterable_dir.iterate();
48324832 while (try dir_it.next()) |entry| {
4833 const is_dir = entry.kind == .Directory;
4833 const is_dir = entry.kind == .directory;
48344834
48354835 if (is_dir and (mem.eql(u8, entry.name, "zig-cache") or mem.eql(u8, entry.name, "zig-out"))) continue;
48364836
4837 if (is_dir or entry.kind == .File and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) {
4837 if (is_dir or entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) {
48384838 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });
48394839 defer fmt.gpa.free(full_path);
48404840
......@@ -4864,7 +4864,7 @@ fn fmtPathFile(
48644864
48654865 const stat = try source_file.stat();
48664866
4867 if (stat.kind == .Directory)
4867 if (stat.kind == .directory)
48684868 return error.IsDir;
48694869
48704870 const gpa = fmt.gpa;
test/src/Cases.zig+2-2
......@@ -349,7 +349,7 @@ fn addFromDirInner(
349349 var filenames = std.ArrayList([]const u8).init(ctx.arena);
350350
351351 while (try it.next()) |entry| {
352 if (entry.kind != .File) continue;
352 if (entry.kind != .file) continue;
353353
354354 // Ignore stuff such as .swp files
355355 switch (Compilation.classifyFileExt(entry.basename)) {
......@@ -1039,7 +1039,7 @@ pub fn main() !void {
10391039 const stem = case_file_path[case_dirname.len + 1 .. case_file_path.len - "0.zig".len];
10401040 var it = iterable_dir.iterate();
10411041 while (try it.next()) |entry| {
1042 if (entry.kind != .File) continue;
1042 if (entry.kind != .file) continue;
10431043 if (!std.mem.startsWith(u8, entry.name, stem)) continue;
10441044 try filenames.append(try std.fs.path.join(arena, &.{ case_dirname, entry.name }));
10451045 }
tools/process_headers.zig+2-2
......@@ -393,8 +393,8 @@ pub fn main() !void {
393393 while (try dir_it.next()) |entry| {
394394 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name });
395395 switch (entry.kind) {
396 .Directory => try dir_stack.append(full_path),
397 .File => {
396 .directory => try dir_stack.append(full_path),
397 .file => {
398398 const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);
399399 const max_size = 2 * 1024 * 1024 * 1024;
400400 const raw_bytes = try std.fs.cwd().readFileAlloc(allocator, full_path, max_size);
tools/update-linux-headers.zig+2-2
......@@ -193,8 +193,8 @@ pub fn main() !void {
193193 while (try dir_it.next()) |entry| {
194194 const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });
195195 switch (entry.kind) {
196 .Directory => try dir_stack.append(full_path),
197 .File => {
196 .directory => try dir_stack.append(full_path),
197 .file => {
198198 const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);
199199 const max_size = 2 * 1024 * 1024 * 1024;
200200 const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size);
tools/update_glibc.zig+2-2
......@@ -57,7 +57,7 @@ pub fn main() !void {
5757 defer walker.deinit();
5858
5959 walk: while (try walker.next()) |entry| {
60 if (entry.kind != .File) continue;
60 if (entry.kind != .file) continue;
6161 if (mem.startsWith(u8, entry.basename, ".")) continue;
6262 for (exempt_files) |p| {
6363 if (mem.eql(u8, entry.path, p)) continue :walk;
......@@ -98,7 +98,7 @@ pub fn main() !void {
9898 defer walker.deinit();
9999
100100 walk: while (try walker.next()) |entry| {
101 if (entry.kind != .File) continue;
101 if (entry.kind != .file) continue;
102102 if (mem.startsWith(u8, entry.basename, ".")) continue;
103103 for (exempt_files) |p| {
104104 if (mem.eql(u8, entry.path, p)) continue :walk;
tools/update_spirv_features.zig+1-1
......@@ -227,7 +227,7 @@ fn gather_extensions(allocator: Allocator, spirv_registry_root: []const u8) ![]c
227227
228228 var vendor_it = extensions_dir.iterate();
229229 while (try vendor_it.next()) |vendor_entry| {
230 std.debug.assert(vendor_entry.kind == .Directory); // If this fails, the structure of SPIRV-Registry has changed.
230 std.debug.assert(vendor_entry.kind == .directory); // If this fails, the structure of SPIRV-Registry has changed.
231231
232232 const vendor_dir = try extensions_dir.dir.openIterableDir(vendor_entry.name, .{});
233233 var ext_it = vendor_dir.iterate();