diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index e991aff5b5..4db8f18a31 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -408,7 +408,7 @@ pub const Manifest = struct { if (self.cache.manifest_dir.createFile(&manifest_file_path, .{ .read = true, .truncate = false, - .lock = .Exclusive, + .lock = .exclusive, .lock_nonblocking = self.want_shared_lock, })) |manifest_file| { self.manifest_file = manifest_file; @@ -418,7 +418,7 @@ pub const Manifest = struct { error.WouldBlock => { self.manifest_file = try self.cache.manifest_dir.openFile(&manifest_file_path, .{ .mode = .read_write, - .lock = .Shared, + .lock = .shared, }); break; }, @@ -885,7 +885,7 @@ pub const Manifest = struct { // Here we intentionally have a period where the lock is released, in case there are // other processes holding a shared lock. manifest_file.unlock(); - try manifest_file.lock(.Exclusive); + try manifest_file.lock(.exclusive); } self.have_exclusive_lock = true; return true; diff --git a/lib/std/Build/Step/InstallDir.zig b/lib/std/Build/Step/InstallDir.zig index 28280dcb7f..597601ce4e 100644 --- a/lib/std/Build/Step/InstallDir.zig +++ b/lib/std/Build/Step/InstallDir.zig @@ -80,8 +80,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { const cwd = fs.cwd(); switch (entry.kind) { - .Directory => try cwd.makePath(dest_path), - .File => { + .directory => try cwd.makePath(dest_path), + .file => { for (self.options.blank_extensions) |ext| { if (mem.endsWith(u8, entry.path, ext)) { try dest_builder.truncateFile(dest_path); diff --git a/lib/std/crypto/Certificate/Bundle.zig b/lib/std/crypto/Certificate/Bundle.zig index fe1ef4c0c3..434de6e0a8 100644 --- a/lib/std/crypto/Certificate/Bundle.zig +++ b/lib/std/crypto/Certificate/Bundle.zig @@ -169,7 +169,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.IterableDir var it = iterable_dir.iterate(); while (try it.next()) |entry| { switch (entry.kind) { - .File, .SymLink => {}, + .file, .sym_link => {}, else => continue, } diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index eea1ec75be..c8d41d3eb0 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -62,9 +62,9 @@ pub const Loop = struct { pub const Overlapped = @TypeOf(overlapped_init); pub const Id = enum { - Basic, - Stop, - EventFd, + basic, + stop, + event_fd, }; pub const EventFd = switch (builtin.os.tag) { @@ -165,11 +165,11 @@ pub const Loop = struct { .available_eventfd_resume_nodes = std.atomic.Stack(ResumeNode.EventFd).init(), .eventfd_resume_nodes = undefined, .final_resume_node = ResumeNode{ - .id = ResumeNode.Id.Stop, + .id = .stop, .handle = undefined, .overlapped = ResumeNode.overlapped_init, }, - .fs_end_request = .{ .data = .{ .msg = .end, .finish = .NoAction } }, + .fs_end_request = .{ .data = .{ .msg = .end, .finish = .no_action } }, .fs_queue = std.atomic.Queue(Request).init(), .fs_thread = undefined, .fs_thread_wakeup = .{}, @@ -224,7 +224,7 @@ pub const Loop = struct { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ - .id = .EventFd, + .id = .event_fd, .handle = undefined, .overlapped = ResumeNode.overlapped_init, }, @@ -282,7 +282,7 @@ pub const Loop = struct { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ - .id = ResumeNode.Id.EventFd, + .id = .event_fd, .handle = undefined, .overlapped = ResumeNode.overlapped_init, }, @@ -347,7 +347,7 @@ pub const Loop = struct { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ - .id = ResumeNode.Id.EventFd, + .id = .event_fd, .handle = undefined, .overlapped = ResumeNode.overlapped_init, }, @@ -413,7 +413,7 @@ pub const Loop = struct { eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ .data = ResumeNode.EventFd{ .base = ResumeNode{ - .id = ResumeNode.Id.EventFd, + .id = .event_fd, .handle = undefined, .overlapped = ResumeNode.overlapped_init, }, @@ -503,7 +503,7 @@ pub const Loop = struct { assert(flags & os.linux.EPOLL.ONESHOT == os.linux.EPOLL.ONESHOT); var resume_node = ResumeNode.Basic{ .base = ResumeNode{ - .id = .Basic, + .id = .basic, .handle = @frame(), .overlapped = ResumeNode.overlapped_init, }, @@ -590,7 +590,7 @@ pub const Loop = struct { pub fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, flags: u16) void { var resume_node = ResumeNode.Basic{ .base = ResumeNode{ - .id = ResumeNode.Id.Basic, + .id = .basic, .handle = @frame(), .overlapped = ResumeNode.overlapped_init, }, @@ -1019,7 +1019,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1041,7 +1041,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1055,7 +1055,7 @@ pub const Loop = struct { var req_node = Request.Node{ .data = .{ .msg = .{ .close = .{ .fd = fd } }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1076,7 +1076,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1109,7 +1109,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1143,7 +1143,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1177,7 +1177,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1210,7 +1210,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1243,7 +1243,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1277,7 +1277,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1311,7 +1311,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1391,7 +1391,7 @@ pub const Loop = struct { .result = undefined, }, }, - .finish = .{ .TickNode = .{ .data = @frame() } }, + .finish = .{ .tick_node = .{ .data = @frame() } }, }, }; suspend { @@ -1419,9 +1419,9 @@ pub const Loop = struct { const handle = resume_node.handle; const resume_node_id = resume_node.id; switch (resume_node_id) { - .Basic => {}, - .Stop => return, - .EventFd => { + .basic => {}, + .stop => return, + .event_fd => { const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); event_fd_node.epoll_op = os.linux.EPOLL.CTL_MOD; const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); @@ -1429,7 +1429,7 @@ pub const Loop = struct { }, } resume handle; - if (resume_node_id == ResumeNode.Id.EventFd) { + if (resume_node_id == .event_fd) { self.finishOneEvent(); } } @@ -1443,19 +1443,19 @@ pub const Loop = struct { const handle = resume_node.handle; const resume_node_id = resume_node.id; switch (resume_node_id) { - .Basic => { + .basic => { const basic_node = @fieldParentPtr(ResumeNode.Basic, "base", resume_node); basic_node.kev = ev; }, - .Stop => return, - .EventFd => { + .stop => return, + .event_fd => { const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); self.available_eventfd_resume_nodes.push(stack_node); }, } resume handle; - if (resume_node_id == ResumeNode.Id.EventFd) { + if (resume_node_id == .event_fd) { self.finishOneEvent(); } } @@ -1477,9 +1477,9 @@ pub const Loop = struct { const handle = resume_node.handle; const resume_node_id = resume_node.id; switch (resume_node_id) { - .Basic => {}, - .Stop => return, - .EventFd => { + .basic => {}, + .stop => return, + .event_fd => { const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); self.available_eventfd_resume_nodes.push(stack_node); @@ -1549,8 +1549,8 @@ pub const Loop = struct { .close => |*msg| os.close(msg.fd), } switch (node.data.finish) { - .TickNode => |*tick_node| self.onNextTick(tick_node), - .NoAction => {}, + .tick_node => |*tick_node| self.onNextTick(tick_node), + .no_action => {}, } self.finishOneEvent(); } @@ -1586,8 +1586,8 @@ pub const Loop = struct { pub const Node = std.atomic.Queue(Request).Node; pub const Finish = union(enum) { - TickNode: Loop.NextTickNode, - NoAction, + tick_node: Loop.NextTickNode, + no_action, }; pub const Msg = union(enum) { diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 38a7975ffd..ac1f86cce5 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt; pub const default_max_depth = 3; pub const Alignment = enum { - Left, - Center, - Right, + left, + center, + right, }; pub const FormatOptions = struct { precision: ?usize = null, width: ?usize = null, - alignment: Alignment = .Right, + alignment: Alignment = .right, fill: u8 = ' ', }; @@ -252,11 +252,11 @@ pub const Placeholder = struct { else => {}, } break :init switch (ch) { - '<' => .Left, - '^' => .Center, - else => .Right, + '<' => .left, + '^' => .center, + else => .right, }; - } else .Right; + } else .right; // Parse the width parameter const width = comptime parser.specifier() catch |err| @@ -1034,18 +1034,18 @@ pub fn formatBuf( return writer.writeAll(buf); switch (options.alignment) { - .Left => { + .left => { try writer.writeAll(buf); try writer.writeByteNTimes(options.fill, padding); }, - .Center => { + .center => { const left_padding = padding / 2; const right_padding = (padding + 1) / 2; try writer.writeByteNTimes(options.fill, left_padding); try writer.writeAll(buf); try writer.writeByteNTimes(options.fill, right_padding); }, - .Right => { + .right => { try writer.writeByteNTimes(options.fill, padding); try writer.writeAll(buf); }, @@ -1742,9 +1742,9 @@ pub fn Formatter(comptime format_fn: anytype) type { /// See also `parseUnsigned`. pub fn parseInt(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T { if (buf.len == 0) return error.InvalidCharacter; - if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .Pos); - if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .Neg); - return parseWithSign(T, buf, radix, .Pos); + if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .pos); + if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .neg); + return parseWithSign(T, buf, radix, .pos); } test "parseInt" { @@ -1805,7 +1805,7 @@ fn parseWithSign( comptime T: type, buf: []const u8, radix: u8, - comptime sign: enum { Pos, Neg }, + comptime sign: enum { pos, neg }, ) ParseIntError!T { if (buf.len == 0) return error.InvalidCharacter; @@ -1835,8 +1835,8 @@ fn parseWithSign( } const add = switch (sign) { - .Pos => math.add, - .Neg => math.sub, + .pos => math.add, + .neg => math.sub, }; var x: T = 0; @@ -1866,7 +1866,7 @@ fn parseWithSign( /// Ignores '_' character in `buf`. /// See also `parseInt`. pub fn parseUnsigned(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T { - return parseWithSign(T, buf, radix, .Pos); + return parseWithSign(T, buf, radix, .pos); } test "parseUnsigned" { diff --git a/lib/std/fs.zig b/lib/std/fs.zig index 041e49d549..6ab2dbaa7f 100644 --- a/lib/std/fs.zig +++ b/lib/std/fs.zig @@ -385,16 +385,16 @@ pub const IterableDir = struct { continue :start_over; } - const entry_kind = switch (darwin_entry.d_type) { - os.DT.BLK => Entry.Kind.BlockDevice, - os.DT.CHR => Entry.Kind.CharacterDevice, - os.DT.DIR => Entry.Kind.Directory, - os.DT.FIFO => Entry.Kind.NamedPipe, - os.DT.LNK => Entry.Kind.SymLink, - os.DT.REG => Entry.Kind.File, - os.DT.SOCK => Entry.Kind.UnixDomainSocket, - os.DT.WHT => Entry.Kind.Whiteout, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (darwin_entry.d_type) { + os.DT.BLK => .block_device, + os.DT.CHR => .character_device, + os.DT.DIR => .directory, + os.DT.FIFO => .named_pipe, + os.DT.LNK => .sym_link, + os.DT.REG => .file, + os.DT.SOCK => .unix_domain_socket, + os.DT.WHT => .whiteout, + else => .unknown, }; return Entry{ .name = name, @@ -442,17 +442,17 @@ pub const IterableDir = struct { error.FileNotFound => unreachable, // lost the race else => |e| return e, }; - const entry_kind = switch (stat_info.mode & os.S.IFMT) { - os.S.IFIFO => Entry.Kind.NamedPipe, - os.S.IFCHR => Entry.Kind.CharacterDevice, - os.S.IFDIR => Entry.Kind.Directory, - os.S.IFBLK => Entry.Kind.BlockDevice, - os.S.IFREG => Entry.Kind.File, - os.S.IFLNK => Entry.Kind.SymLink, - os.S.IFSOCK => Entry.Kind.UnixDomainSocket, - os.S.IFDOOR => Entry.Kind.Door, - os.S.IFPORT => Entry.Kind.EventPort, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (stat_info.mode & os.S.IFMT) { + os.S.IFIFO => .named_pipe, + os.S.IFCHR => .character_device, + os.S.IFDIR => .directory, + os.S.IFBLK => .block_device, + os.S.IFREG => .file, + os.S.IFLNK => .sym_link, + os.S.IFSOCK => .unix_domain_socket, + os.S.IFDOOR => .door, + os.S.IFPORT => .event_port, + else => .unknown, }; return Entry{ .name = name, @@ -501,16 +501,16 @@ pub const IterableDir = struct { continue :start_over; } - const entry_kind = switch (bsd_entry.d_type) { - os.DT.BLK => Entry.Kind.BlockDevice, - os.DT.CHR => Entry.Kind.CharacterDevice, - os.DT.DIR => Entry.Kind.Directory, - os.DT.FIFO => Entry.Kind.NamedPipe, - os.DT.LNK => Entry.Kind.SymLink, - os.DT.REG => Entry.Kind.File, - os.DT.SOCK => Entry.Kind.UnixDomainSocket, - os.DT.WHT => Entry.Kind.Whiteout, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (bsd_entry.d_type) { + os.DT.BLK => .block_device, + os.DT.CHR => .character_device, + os.DT.DIR => .directory, + os.DT.FIFO => .named_pipe, + os.DT.LNK => .sym_link, + os.DT.REG => .file, + os.DT.SOCK => .unix_domain_socket, + os.DT.WHT => .whiteout, + else => .unknown, }; return Entry{ .name = name, @@ -595,14 +595,14 @@ pub const IterableDir = struct { } const statmode = stat_info.mode & os.S.IFMT; - const entry_kind = switch (statmode) { - os.S.IFDIR => Entry.Kind.Directory, - os.S.IFBLK => Entry.Kind.BlockDevice, - os.S.IFCHR => Entry.Kind.CharacterDevice, - os.S.IFLNK => Entry.Kind.SymLink, - os.S.IFREG => Entry.Kind.File, - os.S.IFIFO => Entry.Kind.NamedPipe, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (statmode) { + os.S.IFDIR => .directory, + os.S.IFBLK => .block_device, + os.S.IFCHR => .character_device, + os.S.IFLNK => .sym_link, + os.S.IFREG => .file, + os.S.IFIFO => .named_pipe, + else => .unknown, }; return Entry{ @@ -679,15 +679,15 @@ pub const IterableDir = struct { continue :start_over; } - const entry_kind = switch (linux_entry.d_type) { - linux.DT.BLK => Entry.Kind.BlockDevice, - linux.DT.CHR => Entry.Kind.CharacterDevice, - linux.DT.DIR => Entry.Kind.Directory, - linux.DT.FIFO => Entry.Kind.NamedPipe, - linux.DT.LNK => Entry.Kind.SymLink, - linux.DT.REG => Entry.Kind.File, - linux.DT.SOCK => Entry.Kind.UnixDomainSocket, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (linux_entry.d_type) { + linux.DT.BLK => .block_device, + linux.DT.CHR => .character_device, + linux.DT.DIR => .directory, + linux.DT.FIFO => .named_pipe, + linux.DT.LNK => .sym_link, + linux.DT.REG => .file, + linux.DT.SOCK => .unix_domain_socket, + else => .unknown, }; return Entry{ .name = name, @@ -761,11 +761,11 @@ pub const IterableDir = struct { // Trust that Windows gives us valid UTF-16LE const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable; const name_utf8 = self.name_data[0..name_utf8_len]; - const kind = blk: { + const kind: Entry.Kind = blk: { const attrs = dir_info.FileAttributes; - if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.Directory; - if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk Entry.Kind.SymLink; - break :blk Entry.Kind.File; + if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk .directory; + if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk .sym_link; + break :blk .file; }; return Entry{ .name = name_utf8, @@ -850,14 +850,14 @@ pub const IterableDir = struct { continue :start_over; } - const entry_kind = switch (entry.d_type) { - .BLOCK_DEVICE => Entry.Kind.BlockDevice, - .CHARACTER_DEVICE => Entry.Kind.CharacterDevice, - .DIRECTORY => Entry.Kind.Directory, - .SYMBOLIC_LINK => Entry.Kind.SymLink, - .REGULAR_FILE => Entry.Kind.File, - .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket, - else => Entry.Kind.Unknown, + const entry_kind: Entry.Kind = switch (entry.d_type) { + .BLOCK_DEVICE => .block_device, + .CHARACTER_DEVICE => .character_device, + .DIRECTORY => .directory, + .SYMBOLIC_LINK => .sym_link, + .REGULAR_FILE => .file, + .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, + else => .unknown, }; return Entry{ .name = name, @@ -964,7 +964,7 @@ pub const IterableDir = struct { dirname_len += 1; } try self.name_buffer.appendSlice(base.name); - if (base.kind == .Directory) { + if (base.kind == .directory) { var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) { error.NameTooLong => unreachable, // no path sep in base.name else => |e| return e, @@ -1157,9 +1157,9 @@ pub const Dir = struct { else 0; os_flags |= switch (flags.lock) { - .None => @as(u32, 0), - .Shared => os.O.SHLOCK | nonblocking_lock_flag, - .Exclusive => os.O.EXLOCK | nonblocking_lock_flag, + .none => @as(u32, 0), + .shared => os.O.SHLOCK | nonblocking_lock_flag, + .exclusive => os.O.EXLOCK | nonblocking_lock_flag, }; } if (@hasDecl(os.O, "LARGEFILE")) { @@ -1182,13 +1182,13 @@ pub const Dir = struct { // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block // since it is not compiltime-known and we need to avoid undefined symbol in Wasm. if (builtin.target.os.tag != .wasi) { - if (!has_flock_open_flags and flags.lock != .None) { + if (!has_flock_open_flags and flags.lock != .none) { // TODO: integrate async I/O const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0); try os.flock(fd, switch (flags.lock) { - .None => unreachable, - .Shared => os.LOCK.SH | lock_nonblocking, - .Exclusive => os.LOCK.EX | lock_nonblocking, + .none => unreachable, + .shared => os.LOCK.SH | lock_nonblocking, + .exclusive => os.LOCK.EX | lock_nonblocking, }); } } @@ -1241,9 +1241,9 @@ pub const Dir = struct { const range_off: w.LARGE_INTEGER = 0; const range_len: w.LARGE_INTEGER = 1; const exclusive = switch (flags.lock) { - .None => return file, - .Shared => false, - .Exclusive => true, + .none => return file, + .shared => false, + .exclusive => true, }; try w.LockFile( file.handle, @@ -1320,9 +1320,9 @@ pub const Dir = struct { else 0; const lock_flag: u32 = if (has_flock_open_flags) switch (flags.lock) { - .None => @as(u32, 0), - .Shared => os.O.SHLOCK | nonblocking_lock_flag, - .Exclusive => os.O.EXLOCK | nonblocking_lock_flag, + .none => @as(u32, 0), + .shared => os.O.SHLOCK | nonblocking_lock_flag, + .exclusive => os.O.EXLOCK | nonblocking_lock_flag, } else 0; const O_LARGEFILE = if (@hasDecl(os.O, "LARGEFILE")) os.O.LARGEFILE else 0; @@ -1339,13 +1339,13 @@ pub const Dir = struct { // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block // since it is not compiltime-known and we need to avoid undefined symbol in Wasm. if (builtin.target.os.tag != .wasi) { - if (!has_flock_open_flags and flags.lock != .None) { + if (!has_flock_open_flags and flags.lock != .none) { // TODO: integrate async I/O const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0); try os.flock(fd, switch (flags.lock) { - .None => unreachable, - .Shared => os.LOCK.SH | lock_nonblocking, - .Exclusive => os.LOCK.EX | lock_nonblocking, + .none => unreachable, + .shared => os.LOCK.SH | lock_nonblocking, + .exclusive => os.LOCK.EX | lock_nonblocking, }); } } @@ -1402,9 +1402,9 @@ pub const Dir = struct { const range_off: w.LARGE_INTEGER = 0; const range_len: w.LARGE_INTEGER = 1; const exclusive = switch (flags.lock) { - .None => return file, - .Shared => false, - .Exclusive => true, + .none => return file, + .shared => false, + .exclusive => true, }; try w.LockFile( file.handle, @@ -2106,7 +2106,7 @@ pub const Dir = struct { /// this function recursively removes its entries and then tries again. /// This operation is not atomic on most file systems. pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void { - var initial_iterable_dir = (try self.deleteTreeOpenInitialSubpath(sub_path, .File)) orelse return; + var initial_iterable_dir = (try self.deleteTreeOpenInitialSubpath(sub_path, .file)) orelse return; const StackItem = struct { name: []const u8, @@ -2130,7 +2130,7 @@ pub const Dir = struct { process_stack: while (stack.len != 0) { var top = &(stack.slice()[stack.len - 1]); while (try top.iter.next()) |entry| { - var treat_as_dir = entry.kind == .Directory; + var treat_as_dir = entry.kind == .directory; handle_entry: while (true) { if (treat_as_dir) { if (stack.ensureUnusedCapacity(1)) { @@ -2291,7 +2291,7 @@ pub const Dir = struct { /// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size. /// This is slower than `deleteTree` but uses less stack space. pub fn deleteTreeMinStackSize(self: Dir, sub_path: []const u8) DeleteTreeError!void { - return self.deleteTreeMinStackSizeWithKindHint(sub_path, .File); + return self.deleteTreeMinStackSizeWithKindHint(sub_path, .file); } fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void { @@ -2316,7 +2316,7 @@ pub const Dir = struct { scan_dir: while (true) { var dir_it = iterable_dir.iterateAssumeFirstIteration(); dir_it: while (try dir_it.next()) |entry| { - var treat_as_dir = entry.kind == .Directory; + var treat_as_dir = entry.kind == .directory; handle_entry: while (true) { if (treat_as_dir) { const new_dir = iterable_dir.dir.openIterableDir(entry.name, .{ .no_follow = true }) catch |err| switch (err) { @@ -2407,7 +2407,7 @@ pub const Dir = struct { fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File.Kind) !?IterableDir { return iterable_dir: { // Treat as a file by default - var treat_as_dir = kind_hint == .Directory; + var treat_as_dir = kind_hint == .directory; handle_entry: while (true) { if (treat_as_dir) { diff --git a/lib/std/fs/file.zig b/lib/std/fs/file.zig index 23021a26f5..3ed4b07a3d 100644 --- a/lib/std/fs/file.zig +++ b/lib/std/fs/file.zig @@ -35,17 +35,17 @@ pub const File = struct { pub const Gid = os.gid_t; pub const Kind = enum { - BlockDevice, - CharacterDevice, - Directory, - NamedPipe, - SymLink, - File, - UnixDomainSocket, - Whiteout, - Door, - EventPort, - Unknown, + block_device, + character_device, + directory, + named_pipe, + sym_link, + file, + unix_domain_socket, + whiteout, + door, + event_port, + unknown, }; /// This is the default mode given to POSIX operating systems for creating @@ -81,7 +81,11 @@ pub const File = struct { read_write, }; - pub const Lock = enum { None, Shared, Exclusive }; + pub const Lock = enum { + none, + shared, + exclusive, + }; pub const OpenFlags = struct { mode: OpenMode = .read_only, @@ -110,7 +114,7 @@ pub const File = struct { /// * Windows /// /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt - lock: Lock = .None, + 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 @@ -174,7 +178,7 @@ pub const File = struct { /// * Windows /// /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt - lock: Lock = .None, + 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 @@ -329,32 +333,32 @@ pub const File = struct { const mtime = st.mtime(); const ctime = st.ctime(); const kind: Kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) { - .BLOCK_DEVICE => Kind.BlockDevice, - .CHARACTER_DEVICE => Kind.CharacterDevice, - .DIRECTORY => Kind.Directory, - .SYMBOLIC_LINK => Kind.SymLink, - .REGULAR_FILE => Kind.File, - .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket, - else => Kind.Unknown, + .BLOCK_DEVICE => .block_device, + .CHARACTER_DEVICE => .character_device, + .DIRECTORY => .directory, + .SYMBOLIC_LINK => .sym_link, + .REGULAR_FILE => .file, + .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, + else => .unknown, } else blk: { const m = st.mode & os.S.IFMT; switch (m) { - os.S.IFBLK => break :blk Kind.BlockDevice, - os.S.IFCHR => break :blk Kind.CharacterDevice, - os.S.IFDIR => break :blk Kind.Directory, - os.S.IFIFO => break :blk Kind.NamedPipe, - os.S.IFLNK => break :blk Kind.SymLink, - os.S.IFREG => break :blk Kind.File, - os.S.IFSOCK => break :blk Kind.UnixDomainSocket, + os.S.IFBLK => break :blk .block_device, + os.S.IFCHR => break :blk .character_device, + os.S.IFDIR => break :blk .directory, + os.S.IFIFO => break :blk .named_pipe, + os.S.IFLNK => break :blk .sym_link, + os.S.IFREG => break :blk .file, + os.S.IFSOCK => break :blk .unix_domain_socket, else => {}, } if (builtin.os.tag == .solaris) switch (m) { - os.S.IFDOOR => break :blk Kind.Door, - os.S.IFPORT => break :blk Kind.EventPort, + os.S.IFDOOR => break :blk .door, + os.S.IFPORT => break :blk .event_port, else => {}, }; - break :blk .Unknown; + break :blk .unknown; }; return Stat{ @@ -391,7 +395,7 @@ pub const File = struct { .inode = info.InternalInformation.IndexNumber, .size = @bitCast(u64, info.StandardInformation.EndOfFile), .mode = 0, - .kind = if (info.StandardInformation.Directory == 0) .File else .Directory, + .kind = if (info.StandardInformation.Directory == 0) .file else .directory, .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime), .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime), .ctime = windows.fromSysTime(info.BasicInformation.CreationTime), @@ -609,7 +613,7 @@ pub const File = struct { } /// Returns the `Kind` of file. - /// On Windows, can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown` + /// On Windows, can only return: `.file`, `.directory`, `.sym_link` or `.unknown` pub fn kind(self: Self) Kind { return self.inner.kind(); } @@ -652,35 +656,35 @@ pub const File = struct { /// Returns the `Kind` of the file pub fn kind(self: Self) Kind { if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) { - .BLOCK_DEVICE => Kind.BlockDevice, - .CHARACTER_DEVICE => Kind.CharacterDevice, - .DIRECTORY => Kind.Directory, - .SYMBOLIC_LINK => Kind.SymLink, - .REGULAR_FILE => Kind.File, - .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket, - else => Kind.Unknown, + .BLOCK_DEVICE => .block_device, + .CHARACTER_DEVICE => .character_device, + .DIRECTORY => .directory, + .SYMBOLIC_LINK => .sym_link, + .REGULAR_FILE => .file, + .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, + else => .unknown, }; const m = self.stat.mode & os.S.IFMT; switch (m) { - os.S.IFBLK => return Kind.BlockDevice, - os.S.IFCHR => return Kind.CharacterDevice, - os.S.IFDIR => return Kind.Directory, - os.S.IFIFO => return Kind.NamedPipe, - os.S.IFLNK => return Kind.SymLink, - os.S.IFREG => return Kind.File, - os.S.IFSOCK => return Kind.UnixDomainSocket, + os.S.IFBLK => return .block_device, + os.S.IFCHR => return .character_device, + os.S.IFDIR => return .directory, + os.S.IFIFO => return .named_pipe, + os.S.IFLNK => return .sym_link, + os.S.IFREG => return .file, + os.S.IFSOCK => return .unix_domain_socket, else => {}, } if (builtin.os.tag == .solaris) switch (m) { - os.S.IFDOOR => return Kind.Door, - os.S.IFPORT => return Kind.EventPort, + os.S.IFDOOR => return .door, + os.S.IFPORT => return .event_port, else => {}, }; - return .Unknown; + return .unknown; } /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 @@ -738,17 +742,17 @@ pub const File = struct { const m = self.statx.mode & os.S.IFMT; switch (m) { - os.S.IFBLK => return Kind.BlockDevice, - os.S.IFCHR => return Kind.CharacterDevice, - os.S.IFDIR => return Kind.Directory, - os.S.IFIFO => return Kind.NamedPipe, - os.S.IFLNK => return Kind.SymLink, - os.S.IFREG => return Kind.File, - os.S.IFSOCK => return Kind.UnixDomainSocket, + os.S.IFBLK => return .block_device, + os.S.IFCHR => return .character_device, + os.S.IFDIR => return .directory, + os.S.IFIFO => return .named_pipe, + os.S.IFLNK => return .sym_link, + os.S.IFREG => return .file, + os.S.IFSOCK => return .unix_domain_socket, else => {}, } - return .Unknown; + return .unknown; } /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 @@ -790,18 +794,18 @@ pub const File = struct { } /// Returns the `Kind` of the file. - /// Can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown` + /// Can only return: `.file`, `.directory`, `.sym_link` or `.unknown` pub fn kind(self: Self) Kind { if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) { if (self.reparse_tag & 0x20000000 != 0) { - return .SymLink; + return .sym_link; } } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) { - return .Directory; + return .directory; } else { - return .File; + return .file; } - return .Unknown; + return .unknown; } /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 @@ -1465,9 +1469,9 @@ pub const File = struct { if (is_windows) { var io_status_block: windows.IO_STATUS_BLOCK = undefined; const exclusive = switch (l) { - .None => return, - .Shared => false, - .Exclusive => true, + .none => return, + .shared => false, + .exclusive => true, }; return windows.LockFile( file.handle, @@ -1486,9 +1490,9 @@ pub const File = struct { }; } else { return os.flock(file.handle, switch (l) { - .None => os.LOCK.UN, - .Shared => os.LOCK.SH, - .Exclusive => os.LOCK.EX, + .none => os.LOCK.UN, + .shared => os.LOCK.SH, + .exclusive => os.LOCK.EX, }) catch |err| switch (err) { error.WouldBlock => unreachable, // non-blocking=false else => |e| return e, @@ -1532,9 +1536,9 @@ pub const File = struct { if (is_windows) { var io_status_block: windows.IO_STATUS_BLOCK = undefined; const exclusive = switch (l) { - .None => return, - .Shared => false, - .Exclusive => true, + .none => return, + .shared => false, + .exclusive => true, }; windows.LockFile( file.handle, @@ -1553,9 +1557,9 @@ pub const File = struct { }; } else { os.flock(file.handle, switch (l) { - .None => os.LOCK.UN, - .Shared => os.LOCK.SH | os.LOCK.NB, - .Exclusive => os.LOCK.EX | os.LOCK.NB, + .none => os.LOCK.UN, + .shared => os.LOCK.SH | os.LOCK.NB, + .exclusive => os.LOCK.EX | os.LOCK.NB, }) catch |err| switch (err) { error.WouldBlock => return false, else => |e| return e, diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 15c8307f58..88796e8e4c 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -179,8 +179,8 @@ test "Dir.Iterator" { } try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..' - try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File })); - try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory })); + try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file })); + try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory })); } test "Dir.Iterator many entries" { @@ -214,7 +214,7 @@ test "Dir.Iterator many entries" { i = 0; while (i < num) : (i += 1) { const name = try std.fmt.bufPrint(&buf, "{}", .{i}); - try testing.expect(contains(&entries, .{ .name = name, .kind = .File })); + try testing.expect(contains(&entries, .{ .name = name, .kind = .file })); } } @@ -246,8 +246,8 @@ test "Dir.Iterator twice" { } try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..' - try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File })); - try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory })); + try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file })); + try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory })); } } @@ -280,8 +280,8 @@ test "Dir.Iterator reset" { } try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..' - try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File })); - try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory })); + try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file })); + try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory })); iter.reset(); } @@ -336,7 +336,7 @@ test "Dir.realpath smoke test" { var tmp_dir = tmpDir(.{}); defer tmp_dir.cleanup(); - var file = try tmp_dir.dir.createFile("test_file", .{ .lock = File.Lock.Shared }); + var file = try tmp_dir.dir.createFile("test_file", .{ .lock = .shared }); // We need to close the file immediately as otherwise on Windows we'll end up // with a sharing violation. file.close(); @@ -428,7 +428,7 @@ test "directory operations on files" { // ensure the file still exists and is a file as a sanity check file = try tmp_dir.dir.openFile(test_file_name, .{}); const stat = try file.stat(); - try testing.expect(stat.kind == .File); + try testing.expect(stat.kind == .file); file.close(); } @@ -664,7 +664,7 @@ test "renameAbsolute" { try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(test_file_name, .{})); file = try tmp_dir.dir.openFile(renamed_test_file_name, .{}); const stat = try file.stat(); - try testing.expect(stat.kind == .File); + try testing.expect(stat.kind == .file); file.close(); // Renaming directories @@ -1035,10 +1035,10 @@ test "open file with exclusive nonblocking lock twice" { var tmp = tmpDir(.{}); defer tmp.cleanup(); - const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); + const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); defer file1.close(); - const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); + const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); try testing.expectError(error.WouldBlock, file2); } @@ -1050,10 +1050,10 @@ test "open file with shared and exclusive nonblocking lock" { var tmp = tmpDir(.{}); defer tmp.cleanup(); - const file1 = try tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true }); + const file1 = try tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); defer file1.close(); - const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); + const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); try testing.expectError(error.WouldBlock, file2); } @@ -1065,10 +1065,10 @@ test "open file with exclusive and shared nonblocking lock" { var tmp = tmpDir(.{}); defer tmp.cleanup(); - const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); + const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); defer file1.close(); - const file2 = tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true }); + const file2 = tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); try testing.expectError(error.WouldBlock, file2); } @@ -1085,13 +1085,13 @@ test "open file with exclusive lock twice, make sure second lock waits" { var tmp = tmpDir(.{}); defer tmp.cleanup(); - const file = try tmp.dir.createFile(filename, .{ .lock = .Exclusive }); + const file = try tmp.dir.createFile(filename, .{ .lock = .exclusive }); errdefer file.close(); const S = struct { fn checkFn(dir: *fs.Dir, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void { started.set(); - const file1 = try dir.createFile(filename, .{ .lock = .Exclusive }); + const file1 = try dir.createFile(filename, .{ .lock = .exclusive }); locked.set(); file1.close(); @@ -1138,12 +1138,12 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" { defer gpa.free(filename); const file1 = try fs.createFileAbsolute(filename, .{ - .lock = .Exclusive, + .lock = .exclusive, .lock_nonblocking = true, }); const file2 = fs.createFileAbsolute(filename, .{ - .lock = .Exclusive, + .lock = .exclusive, .lock_nonblocking = true, }); file1.close(); @@ -1348,7 +1348,7 @@ test "File.Metadata" { defer file.close(); const metadata = try file.metadata(); - try testing.expect(metadata.kind() == .File); + try testing.expect(metadata.kind() == .file); try testing.expect(metadata.size() == 0); _ = metadata.accessed(); _ = metadata.modified(); diff --git a/src/Module.zig b/src/Module.zig index c191fd6c7b..61843f5a8f 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -3618,7 +3618,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void { file.sub_file_path, want_local_cache, &digest, }); - break :lock .Shared; + break :lock .shared; }, .parse_failure, .astgen_failure, .success_zir => lock: { const unchanged_metadata = @@ -3633,7 +3633,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void { log.debug("metadata changed: {s}", .{file.sub_file_path}); - break :lock .Exclusive; + break :lock .exclusive; }, }; @@ -3715,11 +3715,11 @@ pub fn astGenFile(mod: *Module, file: *File) !void { } // If we already have the exclusive lock then it is our job to update. - if (builtin.os.tag == .wasi or lock == .Exclusive) break; + if (builtin.os.tag == .wasi or lock == .exclusive) break; // Otherwise, unlock to give someone a chance to get the exclusive lock // and then upgrade to an exclusive lock. cache_file.unlock(); - lock = .Exclusive; + lock = .exclusive; try cache_file.lock(lock); } diff --git a/src/Package.zig b/src/Package.zig index d3ac71af1a..532439c60c 100644 --- a/src/Package.zig +++ b/src/Package.zig @@ -651,8 +651,8 @@ fn computePackageHash( while (try walker.next()) |entry| { switch (entry.kind) { - .Directory => continue, - .File => {}, + .directory => continue, + .file => {}, else => return error.IllegalFileTypeInPackage, } const hashed_file = try arena.create(HashedFile); diff --git a/src/main.zig b/src/main.zig index afda88cebd..f7afbe767b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4830,11 +4830,11 @@ fn fmtPathDir( var dir_it = iterable_dir.iterate(); while (try dir_it.next()) |entry| { - const is_dir = entry.kind == .Directory; + const is_dir = entry.kind == .directory; if (is_dir and (mem.eql(u8, entry.name, "zig-cache") or mem.eql(u8, entry.name, "zig-out"))) continue; - if (is_dir or entry.kind == .File and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) { + if (is_dir or entry.kind == .file and (mem.endsWith(u8, entry.name, ".zig") or mem.endsWith(u8, entry.name, ".zon"))) { const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name }); defer fmt.gpa.free(full_path); @@ -4864,7 +4864,7 @@ fn fmtPathFile( const stat = try source_file.stat(); - if (stat.kind == .Directory) + if (stat.kind == .directory) return error.IsDir; const gpa = fmt.gpa; diff --git a/test/src/Cases.zig b/test/src/Cases.zig index e4f3d532ce..589438297d 100644 --- a/test/src/Cases.zig +++ b/test/src/Cases.zig @@ -349,7 +349,7 @@ fn addFromDirInner( var filenames = std.ArrayList([]const u8).init(ctx.arena); while (try it.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; // Ignore stuff such as .swp files switch (Compilation.classifyFileExt(entry.basename)) { @@ -1039,7 +1039,7 @@ pub fn main() !void { const stem = case_file_path[case_dirname.len + 1 .. case_file_path.len - "0.zig".len]; var it = iterable_dir.iterate(); while (try it.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; if (!std.mem.startsWith(u8, entry.name, stem)) continue; try filenames.append(try std.fs.path.join(arena, &.{ case_dirname, entry.name })); } diff --git a/tools/process_headers.zig b/tools/process_headers.zig index 0321c0e0eb..b93cd07a2c 100644 --- a/tools/process_headers.zig +++ b/tools/process_headers.zig @@ -393,8 +393,8 @@ pub fn main() !void { while (try dir_it.next()) |entry| { const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name }); switch (entry.kind) { - .Directory => try dir_stack.append(full_path), - .File => { + .directory => try dir_stack.append(full_path), + .file => { const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path); const max_size = 2 * 1024 * 1024 * 1024; const raw_bytes = try std.fs.cwd().readFileAlloc(allocator, full_path, max_size); diff --git a/tools/update-linux-headers.zig b/tools/update-linux-headers.zig index 0f31e5e893..d20bc8dd11 100644 --- a/tools/update-linux-headers.zig +++ b/tools/update-linux-headers.zig @@ -193,8 +193,8 @@ pub fn main() !void { while (try dir_it.next()) |entry| { const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name }); switch (entry.kind) { - .Directory => try dir_stack.append(full_path), - .File => { + .directory => try dir_stack.append(full_path), + .file => { const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path); const max_size = 2 * 1024 * 1024 * 1024; const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size); diff --git a/tools/update_glibc.zig b/tools/update_glibc.zig index 24b0f45de7..dcc797f59f 100644 --- a/tools/update_glibc.zig +++ b/tools/update_glibc.zig @@ -57,7 +57,7 @@ pub fn main() !void { defer walker.deinit(); walk: while (try walker.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; if (mem.startsWith(u8, entry.basename, ".")) continue; for (exempt_files) |p| { if (mem.eql(u8, entry.path, p)) continue :walk; @@ -98,7 +98,7 @@ pub fn main() !void { defer walker.deinit(); walk: while (try walker.next()) |entry| { - if (entry.kind != .File) continue; + if (entry.kind != .file) continue; if (mem.startsWith(u8, entry.basename, ".")) continue; for (exempt_files) |p| { if (mem.eql(u8, entry.path, p)) continue :walk; diff --git a/tools/update_spirv_features.zig b/tools/update_spirv_features.zig index 44d8b6a445..31bdf40ef7 100644 --- a/tools/update_spirv_features.zig +++ b/tools/update_spirv_features.zig @@ -227,7 +227,7 @@ fn gather_extensions(allocator: Allocator, spirv_registry_root: []const u8) ![]c var vendor_it = extensions_dir.iterate(); while (try vendor_it.next()) |vendor_entry| { - std.debug.assert(vendor_entry.kind == .Directory); // If this fails, the structure of SPIRV-Registry has changed. + std.debug.assert(vendor_entry.kind == .directory); // If this fails, the structure of SPIRV-Registry has changed. const vendor_dir = try extensions_dir.dir.openIterableDir(vendor_entry.name, .{}); var ext_it = vendor_dir.iterate();