authorgravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2023-05-20 23:06:42+01:00
committergravatar for mail@linusgroh.deLinus Groh <mail@linusgroh.de> 2023-05-25 20:17:07+01:00
log4159add4abe92e903d8797a005344d8325def2fc
treea18989d582306738a92706b1d5cfc846d229ad11
parente96de1b63688d3a92932fe4afdfe37dbe2315f53

std.fs.file: Rename File.Kind enum values to snake case


12 files changed, 153 insertions(+), 153 deletions(-)

lib/std/Build/Step/InstallDir.zig+2-2
...@@ -80,8 +80,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {...@@ -80,8 +80,8 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
80 const cwd = fs.cwd();80 const cwd = fs.cwd();
8181
82 switch (entry.kind) {82 switch (entry.kind) {
83 .Directory => try cwd.makePath(dest_path),83 .directory => try cwd.makePath(dest_path),
84 .File => {84 .file => {
85 for (self.options.blank_extensions) |ext| {85 for (self.options.blank_extensions) |ext| {
86 if (mem.endsWith(u8, entry.path, ext)) {86 if (mem.endsWith(u8, entry.path, ext)) {
87 try dest_builder.truncateFile(dest_path);87 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...@@ -169,7 +169,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.IterableDir
169 var it = iterable_dir.iterate();169 var it = iterable_dir.iterate();
170 while (try it.next()) |entry| {170 while (try it.next()) |entry| {
171 switch (entry.kind) {171 switch (entry.kind) {
172 .File, .SymLink => {},172 .file, .sym_link => {},
173 else => continue,173 else => continue,
174 }174 }
175175
lib/std/fs.zig+66-66
...@@ -385,16 +385,16 @@ pub const IterableDir = struct {...@@ -385,16 +385,16 @@ pub const IterableDir = struct {
385 continue :start_over;385 continue :start_over;
386 }386 }
387387
388 const entry_kind = switch (darwin_entry.d_type) {388 const entry_kind: Entry.Kind = switch (darwin_entry.d_type) {
389 os.DT.BLK => Entry.Kind.BlockDevice,389 os.DT.BLK => .block_device,
390 os.DT.CHR => Entry.Kind.CharacterDevice,390 os.DT.CHR => .character_device,
391 os.DT.DIR => Entry.Kind.Directory,391 os.DT.DIR => .directory,
392 os.DT.FIFO => Entry.Kind.NamedPipe,392 os.DT.FIFO => .named_pipe,
393 os.DT.LNK => Entry.Kind.SymLink,393 os.DT.LNK => .sym_link,
394 os.DT.REG => Entry.Kind.File,394 os.DT.REG => .file,
395 os.DT.SOCK => Entry.Kind.UnixDomainSocket,395 os.DT.SOCK => .unix_domain_socket,
396 os.DT.WHT => Entry.Kind.Whiteout,396 os.DT.WHT => .whiteout,
397 else => Entry.Kind.Unknown,397 else => .unknown,
398 };398 };
399 return Entry{399 return Entry{
400 .name = name,400 .name = name,
...@@ -442,17 +442,17 @@ pub const IterableDir = struct {...@@ -442,17 +442,17 @@ pub const IterableDir = struct {
442 error.FileNotFound => unreachable, // lost the race442 error.FileNotFound => unreachable, // lost the race
443 else => |e| return e,443 else => |e| return e,
444 };444 };
445 const entry_kind = switch (stat_info.mode & os.S.IFMT) {445 const entry_kind: Entry.Kind = switch (stat_info.mode & os.S.IFMT) {
446 os.S.IFIFO => Entry.Kind.NamedPipe,446 os.S.IFIFO => .named_pipe,
447 os.S.IFCHR => Entry.Kind.CharacterDevice,447 os.S.IFCHR => .character_device,
448 os.S.IFDIR => Entry.Kind.Directory,448 os.S.IFDIR => .directory,
449 os.S.IFBLK => Entry.Kind.BlockDevice,449 os.S.IFBLK => .block_device,
450 os.S.IFREG => Entry.Kind.File,450 os.S.IFREG => .file,
451 os.S.IFLNK => Entry.Kind.SymLink,451 os.S.IFLNK => .sym_link,
452 os.S.IFSOCK => Entry.Kind.UnixDomainSocket,452 os.S.IFSOCK => .unix_domain_socket,
453 os.S.IFDOOR => Entry.Kind.Door,453 os.S.IFDOOR => .door,
454 os.S.IFPORT => Entry.Kind.EventPort,454 os.S.IFPORT => .event_port,
455 else => Entry.Kind.Unknown,455 else => .unknown,
456 };456 };
457 return Entry{457 return Entry{
458 .name = name,458 .name = name,
...@@ -501,16 +501,16 @@ pub const IterableDir = struct {...@@ -501,16 +501,16 @@ pub const IterableDir = struct {
501 continue :start_over;501 continue :start_over;
502 }502 }
503503
504 const entry_kind = switch (bsd_entry.d_type) {504 const entry_kind: Entry.Kind = switch (bsd_entry.d_type) {
505 os.DT.BLK => Entry.Kind.BlockDevice,505 os.DT.BLK => .block_device,
506 os.DT.CHR => Entry.Kind.CharacterDevice,506 os.DT.CHR => .character_device,
507 os.DT.DIR => Entry.Kind.Directory,507 os.DT.DIR => .directory,
508 os.DT.FIFO => Entry.Kind.NamedPipe,508 os.DT.FIFO => .named_pipe,
509 os.DT.LNK => Entry.Kind.SymLink,509 os.DT.LNK => .sym_link,
510 os.DT.REG => Entry.Kind.File,510 os.DT.REG => .file,
511 os.DT.SOCK => Entry.Kind.UnixDomainSocket,511 os.DT.SOCK => .unix_domain_socket,
512 os.DT.WHT => Entry.Kind.Whiteout,512 os.DT.WHT => .whiteout,
513 else => Entry.Kind.Unknown,513 else => .unknown,
514 };514 };
515 return Entry{515 return Entry{
516 .name = name,516 .name = name,
...@@ -595,14 +595,14 @@ pub const IterableDir = struct {...@@ -595,14 +595,14 @@ pub const IterableDir = struct {
595 }595 }
596 const statmode = stat_info.mode & os.S.IFMT;596 const statmode = stat_info.mode & os.S.IFMT;
597597
598 const entry_kind = switch (statmode) {598 const entry_kind: Entry.Kind = switch (statmode) {
599 os.S.IFDIR => Entry.Kind.Directory,599 os.S.IFDIR => .directory,
600 os.S.IFBLK => Entry.Kind.BlockDevice,600 os.S.IFBLK => .block_device,
601 os.S.IFCHR => Entry.Kind.CharacterDevice,601 os.S.IFCHR => .character_device,
602 os.S.IFLNK => Entry.Kind.SymLink,602 os.S.IFLNK => .sym_link,
603 os.S.IFREG => Entry.Kind.File,603 os.S.IFREG => .file,
604 os.S.IFIFO => Entry.Kind.NamedPipe,604 os.S.IFIFO => .named_pipe,
605 else => Entry.Kind.Unknown,605 else => .unknown,
606 };606 };
607607
608 return Entry{608 return Entry{
...@@ -679,15 +679,15 @@ pub const IterableDir = struct {...@@ -679,15 +679,15 @@ pub const IterableDir = struct {
679 continue :start_over;679 continue :start_over;
680 }680 }
681681
682 const entry_kind = switch (linux_entry.d_type) {682 const entry_kind: Entry.Kind = switch (linux_entry.d_type) {
683 linux.DT.BLK => Entry.Kind.BlockDevice,683 linux.DT.BLK => .block_device,
684 linux.DT.CHR => Entry.Kind.CharacterDevice,684 linux.DT.CHR => .character_device,
685 linux.DT.DIR => Entry.Kind.Directory,685 linux.DT.DIR => .directory,
686 linux.DT.FIFO => Entry.Kind.NamedPipe,686 linux.DT.FIFO => .named_pipe,
687 linux.DT.LNK => Entry.Kind.SymLink,687 linux.DT.LNK => .sym_link,
688 linux.DT.REG => Entry.Kind.File,688 linux.DT.REG => .file,
689 linux.DT.SOCK => Entry.Kind.UnixDomainSocket,689 linux.DT.SOCK => .unix_domain_socket,
690 else => Entry.Kind.Unknown,690 else => .unknown,
691 };691 };
692 return Entry{692 return Entry{
693 .name = name,693 .name = name,
...@@ -761,11 +761,11 @@ pub const IterableDir = struct {...@@ -761,11 +761,11 @@ pub const IterableDir = struct {
761 // Trust that Windows gives us valid UTF-16LE761 // Trust that Windows gives us valid UTF-16LE
762 const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;762 const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable;
763 const name_utf8 = self.name_data[0..name_utf8_len];763 const name_utf8 = self.name_data[0..name_utf8_len];
764 const kind = blk: {764 const kind: Entry.Kind = blk: {
765 const attrs = dir_info.FileAttributes;765 const attrs = dir_info.FileAttributes;
766 if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk Entry.Kind.Directory;766 if (attrs & w.FILE_ATTRIBUTE_DIRECTORY != 0) break :blk .directory;
767 if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk Entry.Kind.SymLink;767 if (attrs & w.FILE_ATTRIBUTE_REPARSE_POINT != 0) break :blk .sym_link;
768 break :blk Entry.Kind.File;768 break :blk .file;
769 };769 };
770 return Entry{770 return Entry{
771 .name = name_utf8,771 .name = name_utf8,
...@@ -850,14 +850,14 @@ pub const IterableDir = struct {...@@ -850,14 +850,14 @@ pub const IterableDir = struct {
850 continue :start_over;850 continue :start_over;
851 }851 }
852852
853 const entry_kind = switch (entry.d_type) {853 const entry_kind: Entry.Kind = switch (entry.d_type) {
854 .BLOCK_DEVICE => Entry.Kind.BlockDevice,854 .BLOCK_DEVICE => .block_device,
855 .CHARACTER_DEVICE => Entry.Kind.CharacterDevice,855 .CHARACTER_DEVICE => .character_device,
856 .DIRECTORY => Entry.Kind.Directory,856 .DIRECTORY => .directory,
857 .SYMBOLIC_LINK => Entry.Kind.SymLink,857 .SYMBOLIC_LINK => .sym_link,
858 .REGULAR_FILE => Entry.Kind.File,858 .REGULAR_FILE => .file,
859 .SOCKET_STREAM, .SOCKET_DGRAM => Entry.Kind.UnixDomainSocket,859 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
860 else => Entry.Kind.Unknown,860 else => .unknown,
861 };861 };
862 return Entry{862 return Entry{
863 .name = name,863 .name = name,
...@@ -964,7 +964,7 @@ pub const IterableDir = struct {...@@ -964,7 +964,7 @@ pub const IterableDir = struct {
964 dirname_len += 1;964 dirname_len += 1;
965 }965 }
966 try self.name_buffer.appendSlice(base.name);966 try self.name_buffer.appendSlice(base.name);
967 if (base.kind == .Directory) {967 if (base.kind == .directory) {
968 var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) {968 var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) {
969 error.NameTooLong => unreachable, // no path sep in base.name969 error.NameTooLong => unreachable, // no path sep in base.name
970 else => |e| return e,970 else => |e| return e,
...@@ -2106,7 +2106,7 @@ pub const Dir = struct {...@@ -2106,7 +2106,7 @@ pub const Dir = struct {
2106 /// this function recursively removes its entries and then tries again.2106 /// this function recursively removes its entries and then tries again.
2107 /// This operation is not atomic on most file systems.2107 /// This operation is not atomic on most file systems.
2108 pub fn deleteTree(self: Dir, sub_path: []const u8) DeleteTreeError!void {2108 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
2111 const StackItem = struct {2111 const StackItem = struct {
2112 name: []const u8,2112 name: []const u8,
...@@ -2130,7 +2130,7 @@ pub const Dir = struct {...@@ -2130,7 +2130,7 @@ pub const Dir = struct {
2130 process_stack: while (stack.len != 0) {2130 process_stack: while (stack.len != 0) {
2131 var top = &(stack.slice()[stack.len - 1]);2131 var top = &(stack.slice()[stack.len - 1]);
2132 while (try top.iter.next()) |entry| {2132 while (try top.iter.next()) |entry| {
2133 var treat_as_dir = entry.kind == .Directory;2133 var treat_as_dir = entry.kind == .directory;
2134 handle_entry: while (true) {2134 handle_entry: while (true) {
2135 if (treat_as_dir) {2135 if (treat_as_dir) {
2136 if (stack.ensureUnusedCapacity(1)) {2136 if (stack.ensureUnusedCapacity(1)) {
...@@ -2291,7 +2291,7 @@ pub const Dir = struct {...@@ -2291,7 +2291,7 @@ pub const Dir = struct {
2291 /// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size.2291 /// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size.
2292 /// This is slower than `deleteTree` but uses less stack space.2292 /// This is slower than `deleteTree` but uses less stack space.
2293 pub fn deleteTreeMinStackSize(self: Dir, sub_path: []const u8) DeleteTreeError!void {2293 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);
2295 }2295 }
22962296
2297 fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void {2297 fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void {
...@@ -2316,7 +2316,7 @@ pub const Dir = struct {...@@ -2316,7 +2316,7 @@ pub const Dir = struct {
2316 scan_dir: while (true) {2316 scan_dir: while (true) {
2317 var dir_it = iterable_dir.iterateAssumeFirstIteration();2317 var dir_it = iterable_dir.iterateAssumeFirstIteration();
2318 dir_it: while (try dir_it.next()) |entry| {2318 dir_it: while (try dir_it.next()) |entry| {
2319 var treat_as_dir = entry.kind == .Directory;2319 var treat_as_dir = entry.kind == .directory;
2320 handle_entry: while (true) {2320 handle_entry: while (true) {
2321 if (treat_as_dir) {2321 if (treat_as_dir) {
2322 const new_dir = iterable_dir.dir.openIterableDir(entry.name, .{ .no_follow = true }) catch |err| switch (err) {2322 const new_dir = iterable_dir.dir.openIterableDir(entry.name, .{ .no_follow = true }) catch |err| switch (err) {
...@@ -2407,7 +2407,7 @@ pub const Dir = struct {...@@ -2407,7 +2407,7 @@ pub const Dir = struct {
2407 fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File.Kind) !?IterableDir {2407 fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File.Kind) !?IterableDir {
2408 return iterable_dir: {2408 return iterable_dir: {
2409 // Treat as a file by default2409 // Treat as a file by default
2410 var treat_as_dir = kind_hint == .Directory;2410 var treat_as_dir = kind_hint == .directory;
24112411
2412 handle_entry: while (true) {2412 handle_entry: while (true) {
2413 if (treat_as_dir) {2413 if (treat_as_dir) {
lib/std/fs/file.zig+60-60
...@@ -35,17 +35,17 @@ pub const File = struct {...@@ -35,17 +35,17 @@ pub const File = struct {
35 pub const Gid = os.gid_t;35 pub const Gid = os.gid_t;
3636
37 pub const Kind = enum {37 pub const Kind = enum {
38 BlockDevice,38 block_device,
39 CharacterDevice,39 character_device,
40 Directory,40 directory,
41 NamedPipe,41 named_pipe,
42 SymLink,42 sym_link,
43 File,43 file,
44 UnixDomainSocket,44 unix_domain_socket,
45 Whiteout,45 whiteout,
46 Door,46 door,
47 EventPort,47 event_port,
48 Unknown,48 unknown,
49 };49 };
5050
51 /// This is the default mode given to POSIX operating systems for creating51 /// This is the default mode given to POSIX operating systems for creating
...@@ -329,32 +329,32 @@ pub const File = struct {...@@ -329,32 +329,32 @@ pub const File = struct {
329 const mtime = st.mtime();329 const mtime = st.mtime();
330 const ctime = st.ctime();330 const ctime = st.ctime();
331 const kind: Kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) {331 const kind: Kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) {
332 .BLOCK_DEVICE => Kind.BlockDevice,332 .BLOCK_DEVICE => .block_device,
333 .CHARACTER_DEVICE => Kind.CharacterDevice,333 .CHARACTER_DEVICE => .character_device,
334 .DIRECTORY => Kind.Directory,334 .DIRECTORY => .directory,
335 .SYMBOLIC_LINK => Kind.SymLink,335 .SYMBOLIC_LINK => .sym_link,
336 .REGULAR_FILE => Kind.File,336 .REGULAR_FILE => .file,
337 .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,337 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
338 else => Kind.Unknown,338 else => .unknown,
339 } else blk: {339 } else blk: {
340 const m = st.mode & os.S.IFMT;340 const m = st.mode & os.S.IFMT;
341 switch (m) {341 switch (m) {
342 os.S.IFBLK => break :blk Kind.BlockDevice,342 os.S.IFBLK => break :blk .block_device,
343 os.S.IFCHR => break :blk Kind.CharacterDevice,343 os.S.IFCHR => break :blk .character_device,
344 os.S.IFDIR => break :blk Kind.Directory,344 os.S.IFDIR => break :blk .directory,
345 os.S.IFIFO => break :blk Kind.NamedPipe,345 os.S.IFIFO => break :blk .named_pipe,
346 os.S.IFLNK => break :blk Kind.SymLink,346 os.S.IFLNK => break :blk .sym_link,
347 os.S.IFREG => break :blk Kind.File,347 os.S.IFREG => break :blk .file,
348 os.S.IFSOCK => break :blk Kind.UnixDomainSocket,348 os.S.IFSOCK => break :blk .unix_domain_socket,
349 else => {},349 else => {},
350 }350 }
351 if (builtin.os.tag == .solaris) switch (m) {351 if (builtin.os.tag == .solaris) switch (m) {
352 os.S.IFDOOR => break :blk Kind.Door,352 os.S.IFDOOR => break :blk .door,
353 os.S.IFPORT => break :blk Kind.EventPort,353 os.S.IFPORT => break :blk .event_port,
354 else => {},354 else => {},
355 };355 };
356356
357 break :blk .Unknown;357 break :blk .unknown;
358 };358 };
359359
360 return Stat{360 return Stat{
...@@ -391,7 +391,7 @@ pub const File = struct {...@@ -391,7 +391,7 @@ pub const File = struct {
391 .inode = info.InternalInformation.IndexNumber,391 .inode = info.InternalInformation.IndexNumber,
392 .size = @bitCast(u64, info.StandardInformation.EndOfFile),392 .size = @bitCast(u64, info.StandardInformation.EndOfFile),
393 .mode = 0,393 .mode = 0,
394 .kind = if (info.StandardInformation.Directory == 0) .File else .Directory,394 .kind = if (info.StandardInformation.Directory == 0) .file else .directory,
395 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),395 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
396 .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),396 .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),
397 .ctime = windows.fromSysTime(info.BasicInformation.CreationTime),397 .ctime = windows.fromSysTime(info.BasicInformation.CreationTime),
...@@ -609,7 +609,7 @@ pub const File = struct {...@@ -609,7 +609,7 @@ pub const File = struct {
609 }609 }
610610
611 /// Returns the `Kind` of file.611 /// Returns the `Kind` of file.
612 /// On Windows, can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown`612 /// On Windows, can only return: `.file`, `.directory`, `.sym_link` or `.unknown`
613 pub fn kind(self: Self) Kind {613 pub fn kind(self: Self) Kind {
614 return self.inner.kind();614 return self.inner.kind();
615 }615 }
...@@ -652,35 +652,35 @@ pub const File = struct {...@@ -652,35 +652,35 @@ pub const File = struct {
652 /// Returns the `Kind` of the file652 /// Returns the `Kind` of the file
653 pub fn kind(self: Self) Kind {653 pub fn kind(self: Self) Kind {
654 if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) {654 if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) {
655 .BLOCK_DEVICE => Kind.BlockDevice,655 .BLOCK_DEVICE => .block_device,
656 .CHARACTER_DEVICE => Kind.CharacterDevice,656 .CHARACTER_DEVICE => .character_device,
657 .DIRECTORY => Kind.Directory,657 .DIRECTORY => .directory,
658 .SYMBOLIC_LINK => Kind.SymLink,658 .SYMBOLIC_LINK => .sym_link,
659 .REGULAR_FILE => Kind.File,659 .REGULAR_FILE => .file,
660 .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket,660 .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
661 else => Kind.Unknown,661 else => .unknown,
662 };662 };
663663
664 const m = self.stat.mode & os.S.IFMT;664 const m = self.stat.mode & os.S.IFMT;
665665
666 switch (m) {666 switch (m) {
667 os.S.IFBLK => return Kind.BlockDevice,667 os.S.IFBLK => return .block_device,
668 os.S.IFCHR => return Kind.CharacterDevice,668 os.S.IFCHR => return .character_device,
669 os.S.IFDIR => return Kind.Directory,669 os.S.IFDIR => return .directory,
670 os.S.IFIFO => return Kind.NamedPipe,670 os.S.IFIFO => return .named_pipe,
671 os.S.IFLNK => return Kind.SymLink,671 os.S.IFLNK => return .sym_link,
672 os.S.IFREG => return Kind.File,672 os.S.IFREG => return .file,
673 os.S.IFSOCK => return Kind.UnixDomainSocket,673 os.S.IFSOCK => return .unix_domain_socket,
674 else => {},674 else => {},
675 }675 }
676676
677 if (builtin.os.tag == .solaris) switch (m) {677 if (builtin.os.tag == .solaris) switch (m) {
678 os.S.IFDOOR => return Kind.Door,678 os.S.IFDOOR => return .door,
679 os.S.IFPORT => return Kind.EventPort,679 os.S.IFPORT => return .event_port,
680 else => {},680 else => {},
681 };681 };
682682
683 return .Unknown;683 return .unknown;
684 }684 }
685685
686 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01686 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
...@@ -738,17 +738,17 @@ pub const File = struct {...@@ -738,17 +738,17 @@ pub const File = struct {
738 const m = self.statx.mode & os.S.IFMT;738 const m = self.statx.mode & os.S.IFMT;
739739
740 switch (m) {740 switch (m) {
741 os.S.IFBLK => return Kind.BlockDevice,741 os.S.IFBLK => return .block_device,
742 os.S.IFCHR => return Kind.CharacterDevice,742 os.S.IFCHR => return .character_device,
743 os.S.IFDIR => return Kind.Directory,743 os.S.IFDIR => return .directory,
744 os.S.IFIFO => return Kind.NamedPipe,744 os.S.IFIFO => return .named_pipe,
745 os.S.IFLNK => return Kind.SymLink,745 os.S.IFLNK => return .sym_link,
746 os.S.IFREG => return Kind.File,746 os.S.IFREG => return .file,
747 os.S.IFSOCK => return Kind.UnixDomainSocket,747 os.S.IFSOCK => return .unix_domain_socket,
748 else => {},748 else => {},
749 }749 }
750750
751 return .Unknown;751 return .unknown;
752 }752 }
753753
754 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01754 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
...@@ -790,18 +790,18 @@ pub const File = struct {...@@ -790,18 +790,18 @@ pub const File = struct {
790 }790 }
791791
792 /// Returns the `Kind` of the file.792 /// Returns the `Kind` of the file.
793 /// Can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown`793 /// Can only return: `.file`, `.directory`, `.sym_link` or `.unknown`
794 pub fn kind(self: Self) Kind {794 pub fn kind(self: Self) Kind {
795 if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) {795 if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) {
796 if (self.reparse_tag & 0x20000000 != 0) {796 if (self.reparse_tag & 0x20000000 != 0) {
797 return .SymLink;797 return .sym_link;
798 }798 }
799 } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) {799 } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) {
800 return .Directory;800 return .directory;
801 } else {801 } else {
802 return .File;802 return .file;
803 }803 }
804 return .Unknown;804 return .unknown;
805 }805 }
806806
807 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01807 /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01
lib/std/fs/test.zig+10-10
...@@ -179,8 +179,8 @@ test "Dir.Iterator" {...@@ -179,8 +179,8 @@ test "Dir.Iterator" {
179 }179 }
180180
181 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'181 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
182 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));182 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
183 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));183 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
184}184}
185185
186test "Dir.Iterator many entries" {186test "Dir.Iterator many entries" {
...@@ -214,7 +214,7 @@ test "Dir.Iterator many entries" {...@@ -214,7 +214,7 @@ test "Dir.Iterator many entries" {
214 i = 0;214 i = 0;
215 while (i < num) : (i += 1) {215 while (i < num) : (i += 1) {
216 const name = try std.fmt.bufPrint(&buf, "{}", .{i});216 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 }));
218 }218 }
219}219}
220220
...@@ -246,8 +246,8 @@ test "Dir.Iterator twice" {...@@ -246,8 +246,8 @@ test "Dir.Iterator twice" {
246 }246 }
247247
248 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'248 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
249 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));249 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
250 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));250 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
251 }251 }
252}252}
253253
...@@ -280,8 +280,8 @@ test "Dir.Iterator reset" {...@@ -280,8 +280,8 @@ test "Dir.Iterator reset" {
280 }280 }
281281
282 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'282 try testing.expect(entries.items.len == 2); // note that the Iterator skips '.' and '..'
283 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .File }));283 try testing.expect(contains(&entries, .{ .name = "some_file", .kind = .file }));
284 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .Directory }));284 try testing.expect(contains(&entries, .{ .name = "some_dir", .kind = .directory }));
285285
286 iter.reset();286 iter.reset();
287 }287 }
...@@ -428,7 +428,7 @@ test "directory operations on files" {...@@ -428,7 +428,7 @@ test "directory operations on files" {
428 // ensure the file still exists and is a file as a sanity check428 // ensure the file still exists and is a file as a sanity check
429 file = try tmp_dir.dir.openFile(test_file_name, .{});429 file = try tmp_dir.dir.openFile(test_file_name, .{});
430 const stat = try file.stat();430 const stat = try file.stat();
431 try testing.expect(stat.kind == .File);431 try testing.expect(stat.kind == .file);
432 file.close();432 file.close();
433}433}
434434
...@@ -664,7 +664,7 @@ test "renameAbsolute" {...@@ -664,7 +664,7 @@ test "renameAbsolute" {
664 try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(test_file_name, .{}));664 try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(test_file_name, .{}));
665 file = try tmp_dir.dir.openFile(renamed_test_file_name, .{});665 file = try tmp_dir.dir.openFile(renamed_test_file_name, .{});
666 const stat = try file.stat();666 const stat = try file.stat();
667 try testing.expect(stat.kind == .File);667 try testing.expect(stat.kind == .file);
668 file.close();668 file.close();
669669
670 // Renaming directories670 // Renaming directories
...@@ -1348,7 +1348,7 @@ test "File.Metadata" {...@@ -1348,7 +1348,7 @@ test "File.Metadata" {
1348 defer file.close();1348 defer file.close();
13491349
1350 const metadata = try file.metadata();1350 const metadata = try file.metadata();
1351 try testing.expect(metadata.kind() == .File);1351 try testing.expect(metadata.kind() == .file);
1352 try testing.expect(metadata.size() == 0);1352 try testing.expect(metadata.size() == 0);
1353 _ = metadata.accessed();1353 _ = metadata.accessed();
1354 _ = metadata.modified();1354 _ = metadata.modified();
src/Package.zig+2-2
...@@ -651,8 +651,8 @@ fn computePackageHash(...@@ -651,8 +651,8 @@ fn computePackageHash(
651651
652 while (try walker.next()) |entry| {652 while (try walker.next()) |entry| {
653 switch (entry.kind) {653 switch (entry.kind) {
654 .Directory => continue,654 .directory => continue,
655 .File => {},655 .file => {},
656 else => return error.IllegalFileTypeInPackage,656 else => return error.IllegalFileTypeInPackage,
657 }657 }
658 const hashed_file = try arena.create(HashedFile);658 const hashed_file = try arena.create(HashedFile);
src/main.zig+3-3
...@@ -4830,11 +4830,11 @@ fn fmtPathDir(...@@ -4830,11 +4830,11 @@ fn fmtPathDir(
48304830
4831 var dir_it = iterable_dir.iterate();4831 var dir_it = iterable_dir.iterate();
4832 while (try dir_it.next()) |entry| {4832 while (try dir_it.next()) |entry| {
4833 const is_dir = entry.kind == .Directory;4833 const is_dir = entry.kind == .directory;
48344834
4835 if (is_dir and (mem.eql(u8, entry.name, "zig-cache") or mem.eql(u8, entry.name, "zig-out"))) continue;4835 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"))) {
4838 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });4838 const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name });
4839 defer fmt.gpa.free(full_path);4839 defer fmt.gpa.free(full_path);
48404840
...@@ -4864,7 +4864,7 @@ fn fmtPathFile(...@@ -4864,7 +4864,7 @@ fn fmtPathFile(
48644864
4865 const stat = try source_file.stat();4865 const stat = try source_file.stat();
48664866
4867 if (stat.kind == .Directory)4867 if (stat.kind == .directory)
4868 return error.IsDir;4868 return error.IsDir;
48694869
4870 const gpa = fmt.gpa;4870 const gpa = fmt.gpa;
test/src/Cases.zig+2-2
...@@ -349,7 +349,7 @@ fn addFromDirInner(...@@ -349,7 +349,7 @@ fn addFromDirInner(
349 var filenames = std.ArrayList([]const u8).init(ctx.arena);349 var filenames = std.ArrayList([]const u8).init(ctx.arena);
350350
351 while (try it.next()) |entry| {351 while (try it.next()) |entry| {
352 if (entry.kind != .File) continue;352 if (entry.kind != .file) continue;
353353
354 // Ignore stuff such as .swp files354 // Ignore stuff such as .swp files
355 switch (Compilation.classifyFileExt(entry.basename)) {355 switch (Compilation.classifyFileExt(entry.basename)) {
...@@ -1039,7 +1039,7 @@ pub fn main() !void {...@@ -1039,7 +1039,7 @@ pub fn main() !void {
1039 const stem = case_file_path[case_dirname.len + 1 .. case_file_path.len - "0.zig".len];1039 const stem = case_file_path[case_dirname.len + 1 .. case_file_path.len - "0.zig".len];
1040 var it = iterable_dir.iterate();1040 var it = iterable_dir.iterate();
1041 while (try it.next()) |entry| {1041 while (try it.next()) |entry| {
1042 if (entry.kind != .File) continue;1042 if (entry.kind != .file) continue;
1043 if (!std.mem.startsWith(u8, entry.name, stem)) continue;1043 if (!std.mem.startsWith(u8, entry.name, stem)) continue;
1044 try filenames.append(try std.fs.path.join(arena, &.{ case_dirname, entry.name }));1044 try filenames.append(try std.fs.path.join(arena, &.{ case_dirname, entry.name }));
1045 }1045 }
tools/process_headers.zig+2-2
...@@ -393,8 +393,8 @@ pub fn main() !void {...@@ -393,8 +393,8 @@ pub fn main() !void {
393 while (try dir_it.next()) |entry| {393 while (try dir_it.next()) |entry| {
394 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name });394 const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name });
395 switch (entry.kind) {395 switch (entry.kind) {
396 .Directory => try dir_stack.append(full_path),396 .directory => try dir_stack.append(full_path),
397 .File => {397 .file => {
398 const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);398 const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path);
399 const max_size = 2 * 1024 * 1024 * 1024;399 const max_size = 2 * 1024 * 1024 * 1024;
400 const raw_bytes = try std.fs.cwd().readFileAlloc(allocator, full_path, max_size);400 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 {...@@ -193,8 +193,8 @@ pub fn main() !void {
193 while (try dir_it.next()) |entry| {193 while (try dir_it.next()) |entry| {
194 const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });194 const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name });
195 switch (entry.kind) {195 switch (entry.kind) {
196 .Directory => try dir_stack.append(full_path),196 .directory => try dir_stack.append(full_path),
197 .File => {197 .file => {
198 const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);198 const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path);
199 const max_size = 2 * 1024 * 1024 * 1024;199 const max_size = 2 * 1024 * 1024 * 1024;
200 const raw_bytes = try std.fs.cwd().readFileAlloc(arena, full_path, max_size);200 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 {...@@ -57,7 +57,7 @@ pub fn main() !void {
57 defer walker.deinit();57 defer walker.deinit();
5858
59 walk: while (try walker.next()) |entry| {59 walk: while (try walker.next()) |entry| {
60 if (entry.kind != .File) continue;60 if (entry.kind != .file) continue;
61 if (mem.startsWith(u8, entry.basename, ".")) continue;61 if (mem.startsWith(u8, entry.basename, ".")) continue;
62 for (exempt_files) |p| {62 for (exempt_files) |p| {
63 if (mem.eql(u8, entry.path, p)) continue :walk;63 if (mem.eql(u8, entry.path, p)) continue :walk;
...@@ -98,7 +98,7 @@ pub fn main() !void {...@@ -98,7 +98,7 @@ pub fn main() !void {
98 defer walker.deinit();98 defer walker.deinit();
9999
100 walk: while (try walker.next()) |entry| {100 walk: while (try walker.next()) |entry| {
101 if (entry.kind != .File) continue;101 if (entry.kind != .file) continue;
102 if (mem.startsWith(u8, entry.basename, ".")) continue;102 if (mem.startsWith(u8, entry.basename, ".")) continue;
103 for (exempt_files) |p| {103 for (exempt_files) |p| {
104 if (mem.eql(u8, entry.path, p)) continue :walk;104 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...@@ -227,7 +227,7 @@ fn gather_extensions(allocator: Allocator, spirv_registry_root: []const u8) ![]c
227227
228 var vendor_it = extensions_dir.iterate();228 var vendor_it = extensions_dir.iterate();
229 while (try vendor_it.next()) |vendor_entry| {229 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
232 const vendor_dir = try extensions_dir.dir.openIterableDir(vendor_entry.name, .{});232 const vendor_dir = try extensions_dir.dir.openIterableDir(vendor_entry.name, .{});
233 var ext_it = vendor_dir.iterate();233 var ext_it = vendor_dir.iterate();