| author | |
| committer | |
| log | 4159add4abe92e903d8797a005344d8325def2fc |
| tree | a18989d582306738a92706b1d5cfc846d229ad11 |
| parent | e96de1b63688d3a92932fe4afdfe37dbe2315f53 |
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 | 80 | const cwd = fs.cwd(); |
| 81 | 81 | |
| 82 | 82 | switch (entry.kind) { |
| 83 | .Directory => try cwd.makePath(dest_path), | |
| 84 | .File => { | |
| 83 | .directory => try cwd.makePath(dest_path), | |
| 84 | .file => { | |
| 85 | 85 | for (self.options.blank_extensions) |ext| { |
| 86 | 86 | if (mem.endsWith(u8, entry.path, ext)) { |
| 87 | 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 | 169 | var it = iterable_dir.iterate(); |
| 170 | 170 | while (try it.next()) |entry| { |
| 171 | 171 | switch (entry.kind) { |
| 172 | .File, .SymLink => {}, | |
| 172 | .file, .sym_link => {}, | |
| 173 | 173 | else => continue, |
| 174 | 174 | } |
| 175 | 175 |
lib/std/fs.zig+66-66| ... | ... | @@ -385,16 +385,16 @@ pub const IterableDir = struct { |
| 385 | 385 | continue :start_over; |
| 386 | 386 | } |
| 387 | 387 | |
| 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, | |
| 398 | 398 | }; |
| 399 | 399 | return Entry{ |
| 400 | 400 | .name = name, |
| ... | ... | @@ -442,17 +442,17 @@ pub const IterableDir = struct { |
| 442 | 442 | error.FileNotFound => unreachable, // lost the race |
| 443 | 443 | else => |e| return e, |
| 444 | 444 | }; |
| 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, | |
| 456 | 456 | }; |
| 457 | 457 | return Entry{ |
| 458 | 458 | .name = name, |
| ... | ... | @@ -501,16 +501,16 @@ pub const IterableDir = struct { |
| 501 | 501 | continue :start_over; |
| 502 | 502 | } |
| 503 | 503 | |
| 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, | |
| 514 | 514 | }; |
| 515 | 515 | return Entry{ |
| 516 | 516 | .name = name, |
| ... | ... | @@ -595,14 +595,14 @@ pub const IterableDir = struct { |
| 595 | 595 | } |
| 596 | 596 | const statmode = stat_info.mode & os.S.IFMT; |
| 597 | 597 | |
| 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, | |
| 606 | 606 | }; |
| 607 | 607 | |
| 608 | 608 | return Entry{ |
| ... | ... | @@ -679,15 +679,15 @@ pub const IterableDir = struct { |
| 679 | 679 | continue :start_over; |
| 680 | 680 | } |
| 681 | 681 | |
| 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, | |
| 691 | 691 | }; |
| 692 | 692 | return Entry{ |
| 693 | 693 | .name = name, |
| ... | ... | @@ -761,11 +761,11 @@ pub const IterableDir = struct { |
| 761 | 761 | // Trust that Windows gives us valid UTF-16LE |
| 762 | 762 | const name_utf8_len = std.unicode.utf16leToUtf8(self.name_data[0..], name_utf16le) catch unreachable; |
| 763 | 763 | const name_utf8 = self.name_data[0..name_utf8_len]; |
| 764 | const kind = blk: { | |
| 764 | const kind: Entry.Kind = blk: { | |
| 765 | 765 | 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; | |
| 769 | 769 | }; |
| 770 | 770 | return Entry{ |
| 771 | 771 | .name = name_utf8, |
| ... | ... | @@ -850,14 +850,14 @@ pub const IterableDir = struct { |
| 850 | 850 | continue :start_over; |
| 851 | 851 | } |
| 852 | 852 | |
| 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, | |
| 861 | 861 | }; |
| 862 | 862 | return Entry{ |
| 863 | 863 | .name = name, |
| ... | ... | @@ -964,7 +964,7 @@ pub const IterableDir = struct { |
| 964 | 964 | dirname_len += 1; |
| 965 | 965 | } |
| 966 | 966 | try self.name_buffer.appendSlice(base.name); |
| 967 | if (base.kind == .Directory) { | |
| 967 | if (base.kind == .directory) { | |
| 968 | 968 | var new_dir = top.iter.dir.openIterableDir(base.name, .{}) catch |err| switch (err) { |
| 969 | 969 | error.NameTooLong => unreachable, // no path sep in base.name |
| 970 | 970 | else => |e| return e, |
| ... | ... | @@ -2106,7 +2106,7 @@ pub const Dir = struct { |
| 2106 | 2106 | /// this function recursively removes its entries and then tries again. |
| 2107 | 2107 | /// This operation is not atomic on most file systems. |
| 2108 | 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; | |
| 2110 | 2110 | |
| 2111 | 2111 | const StackItem = struct { |
| 2112 | 2112 | name: []const u8, |
| ... | ... | @@ -2130,7 +2130,7 @@ pub const Dir = struct { |
| 2130 | 2130 | process_stack: while (stack.len != 0) { |
| 2131 | 2131 | var top = &(stack.slice()[stack.len - 1]); |
| 2132 | 2132 | while (try top.iter.next()) |entry| { |
| 2133 | var treat_as_dir = entry.kind == .Directory; | |
| 2133 | var treat_as_dir = entry.kind == .directory; | |
| 2134 | 2134 | handle_entry: while (true) { |
| 2135 | 2135 | if (treat_as_dir) { |
| 2136 | 2136 | if (stack.ensureUnusedCapacity(1)) { |
| ... | ... | @@ -2291,7 +2291,7 @@ pub const Dir = struct { |
| 2291 | 2291 | /// Like `deleteTree`, but only keeps one `Iterator` active at a time to minimize the function's stack size. |
| 2292 | 2292 | /// This is slower than `deleteTree` but uses less stack space. |
| 2293 | 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 | } |
| 2296 | 2296 | |
| 2297 | 2297 | fn deleteTreeMinStackSizeWithKindHint(self: Dir, sub_path: []const u8, kind_hint: File.Kind) DeleteTreeError!void { |
| ... | ... | @@ -2316,7 +2316,7 @@ pub const Dir = struct { |
| 2316 | 2316 | scan_dir: while (true) { |
| 2317 | 2317 | var dir_it = iterable_dir.iterateAssumeFirstIteration(); |
| 2318 | 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 | 2320 | handle_entry: while (true) { |
| 2321 | 2321 | if (treat_as_dir) { |
| 2322 | 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 | 2407 | fn deleteTreeOpenInitialSubpath(self: Dir, sub_path: []const u8, kind_hint: File.Kind) !?IterableDir { |
| 2408 | 2408 | return iterable_dir: { |
| 2409 | 2409 | // Treat as a file by default |
| 2410 | var treat_as_dir = kind_hint == .Directory; | |
| 2410 | var treat_as_dir = kind_hint == .directory; | |
| 2411 | 2411 | |
| 2412 | 2412 | handle_entry: while (true) { |
| 2413 | 2413 | if (treat_as_dir) { |
lib/std/fs/file.zig+60-60| ... | ... | @@ -35,17 +35,17 @@ pub const File = struct { |
| 35 | 35 | pub const Gid = os.gid_t; |
| 36 | 36 | |
| 37 | 37 | 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, | |
| 49 | 49 | }; |
| 50 | 50 | |
| 51 | 51 | /// This is the default mode given to POSIX operating systems for creating |
| ... | ... | @@ -329,32 +329,32 @@ pub const File = struct { |
| 329 | 329 | const mtime = st.mtime(); |
| 330 | 330 | const ctime = st.ctime(); |
| 331 | 331 | 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, | |
| 332 | .BLOCK_DEVICE => .block_device, | |
| 333 | .CHARACTER_DEVICE => .character_device, | |
| 334 | .DIRECTORY => .directory, | |
| 335 | .SYMBOLIC_LINK => .sym_link, | |
| 336 | .REGULAR_FILE => .file, | |
| 337 | .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, | |
| 338 | else => .unknown, | |
| 339 | 339 | } else blk: { |
| 340 | 340 | const m = st.mode & os.S.IFMT; |
| 341 | 341 | 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, | |
| 342 | os.S.IFBLK => break :blk .block_device, | |
| 343 | os.S.IFCHR => break :blk .character_device, | |
| 344 | os.S.IFDIR => break :blk .directory, | |
| 345 | os.S.IFIFO => break :blk .named_pipe, | |
| 346 | os.S.IFLNK => break :blk .sym_link, | |
| 347 | os.S.IFREG => break :blk .file, | |
| 348 | os.S.IFSOCK => break :blk .unix_domain_socket, | |
| 349 | 349 | else => {}, |
| 350 | 350 | } |
| 351 | 351 | if (builtin.os.tag == .solaris) switch (m) { |
| 352 | os.S.IFDOOR => break :blk Kind.Door, | |
| 353 | os.S.IFPORT => break :blk Kind.EventPort, | |
| 352 | os.S.IFDOOR => break :blk .door, | |
| 353 | os.S.IFPORT => break :blk .event_port, | |
| 354 | 354 | else => {}, |
| 355 | 355 | }; |
| 356 | 356 | |
| 357 | break :blk .Unknown; | |
| 357 | break :blk .unknown; | |
| 358 | 358 | }; |
| 359 | 359 | |
| 360 | 360 | return Stat{ |
| ... | ... | @@ -391,7 +391,7 @@ pub const File = struct { |
| 391 | 391 | .inode = info.InternalInformation.IndexNumber, |
| 392 | 392 | .size = @bitCast(u64, info.StandardInformation.EndOfFile), |
| 393 | 393 | .mode = 0, |
| 394 | .kind = if (info.StandardInformation.Directory == 0) .File else .Directory, | |
| 394 | .kind = if (info.StandardInformation.Directory == 0) .file else .directory, | |
| 395 | 395 | .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime), |
| 396 | 396 | .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime), |
| 397 | 397 | .ctime = windows.fromSysTime(info.BasicInformation.CreationTime), |
| ... | ... | @@ -609,7 +609,7 @@ pub const File = struct { |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 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 | 613 | pub fn kind(self: Self) Kind { |
| 614 | 614 | return self.inner.kind(); |
| 615 | 615 | } |
| ... | ... | @@ -652,35 +652,35 @@ pub const File = struct { |
| 652 | 652 | /// Returns the `Kind` of the file |
| 653 | 653 | pub fn kind(self: Self) Kind { |
| 654 | 654 | 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, | |
| 655 | .BLOCK_DEVICE => .block_device, | |
| 656 | .CHARACTER_DEVICE => .character_device, | |
| 657 | .DIRECTORY => .directory, | |
| 658 | .SYMBOLIC_LINK => .sym_link, | |
| 659 | .REGULAR_FILE => .file, | |
| 660 | .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, | |
| 661 | else => .unknown, | |
| 662 | 662 | }; |
| 663 | 663 | |
| 664 | 664 | const m = self.stat.mode & os.S.IFMT; |
| 665 | 665 | |
| 666 | 666 | 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, | |
| 667 | os.S.IFBLK => return .block_device, | |
| 668 | os.S.IFCHR => return .character_device, | |
| 669 | os.S.IFDIR => return .directory, | |
| 670 | os.S.IFIFO => return .named_pipe, | |
| 671 | os.S.IFLNK => return .sym_link, | |
| 672 | os.S.IFREG => return .file, | |
| 673 | os.S.IFSOCK => return .unix_domain_socket, | |
| 674 | 674 | else => {}, |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 | if (builtin.os.tag == .solaris) switch (m) { |
| 678 | os.S.IFDOOR => return Kind.Door, | |
| 679 | os.S.IFPORT => return Kind.EventPort, | |
| 678 | os.S.IFDOOR => return .door, | |
| 679 | os.S.IFPORT => return .event_port, | |
| 680 | 680 | else => {}, |
| 681 | 681 | }; |
| 682 | 682 | |
| 683 | return .Unknown; | |
| 683 | return .unknown; | |
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| ... | ... | @@ -738,17 +738,17 @@ pub const File = struct { |
| 738 | 738 | const m = self.statx.mode & os.S.IFMT; |
| 739 | 739 | |
| 740 | 740 | 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, | |
| 741 | os.S.IFBLK => return .block_device, | |
| 742 | os.S.IFCHR => return .character_device, | |
| 743 | os.S.IFDIR => return .directory, | |
| 744 | os.S.IFIFO => return .named_pipe, | |
| 745 | os.S.IFLNK => return .sym_link, | |
| 746 | os.S.IFREG => return .file, | |
| 747 | os.S.IFSOCK => return .unix_domain_socket, | |
| 748 | 748 | else => {}, |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | return .Unknown; | |
| 751 | return .unknown; | |
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| ... | ... | @@ -790,18 +790,18 @@ pub const File = struct { |
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 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 | 794 | pub fn kind(self: Self) Kind { |
| 795 | 795 | if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) { |
| 796 | 796 | if (self.reparse_tag & 0x20000000 != 0) { |
| 797 | return .SymLink; | |
| 797 | return .sym_link; | |
| 798 | 798 | } |
| 799 | 799 | } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) { |
| 800 | return .Directory; | |
| 800 | return .directory; | |
| 801 | 801 | } else { |
| 802 | return .File; | |
| 802 | return .file; | |
| 803 | 803 | } |
| 804 | return .Unknown; | |
| 804 | return .unknown; | |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /// 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 | 179 | } |
| 180 | 180 | |
| 181 | 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 })); | |
| 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 })); | |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | test "Dir.Iterator many entries" { |
| ... | ... | @@ -214,7 +214,7 @@ test "Dir.Iterator many entries" { |
| 214 | 214 | i = 0; |
| 215 | 215 | while (i < num) : (i += 1) { |
| 216 | 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 | } |
| 220 | 220 | |
| ... | ... | @@ -246,8 +246,8 @@ test "Dir.Iterator twice" { |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 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 })); | |
| 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 })); | |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| ... | ... | @@ -280,8 +280,8 @@ test "Dir.Iterator reset" { |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 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 })); | |
| 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 })); | |
| 285 | 285 | |
| 286 | 286 | iter.reset(); |
| 287 | 287 | } |
| ... | ... | @@ -428,7 +428,7 @@ test "directory operations on files" { |
| 428 | 428 | // ensure the file still exists and is a file as a sanity check |
| 429 | 429 | file = try tmp_dir.dir.openFile(test_file_name, .{}); |
| 430 | 430 | const stat = try file.stat(); |
| 431 | try testing.expect(stat.kind == .File); | |
| 431 | try testing.expect(stat.kind == .file); | |
| 432 | 432 | file.close(); |
| 433 | 433 | } |
| 434 | 434 | |
| ... | ... | @@ -664,7 +664,7 @@ test "renameAbsolute" { |
| 664 | 664 | try testing.expectError(error.FileNotFound, tmp_dir.dir.openFile(test_file_name, .{})); |
| 665 | 665 | file = try tmp_dir.dir.openFile(renamed_test_file_name, .{}); |
| 666 | 666 | const stat = try file.stat(); |
| 667 | try testing.expect(stat.kind == .File); | |
| 667 | try testing.expect(stat.kind == .file); | |
| 668 | 668 | file.close(); |
| 669 | 669 | |
| 670 | 670 | // Renaming directories |
| ... | ... | @@ -1348,7 +1348,7 @@ test "File.Metadata" { |
| 1348 | 1348 | defer file.close(); |
| 1349 | 1349 | |
| 1350 | 1350 | const metadata = try file.metadata(); |
| 1351 | try testing.expect(metadata.kind() == .File); | |
| 1351 | try testing.expect(metadata.kind() == .file); | |
| 1352 | 1352 | try testing.expect(metadata.size() == 0); |
| 1353 | 1353 | _ = metadata.accessed(); |
| 1354 | 1354 | _ = metadata.modified(); |
src/Package.zig+2-2| ... | ... | @@ -651,8 +651,8 @@ fn computePackageHash( |
| 651 | 651 | |
| 652 | 652 | while (try walker.next()) |entry| { |
| 653 | 653 | switch (entry.kind) { |
| 654 | .Directory => continue, | |
| 655 | .File => {}, | |
| 654 | .directory => continue, | |
| 655 | .file => {}, | |
| 656 | 656 | else => return error.IllegalFileTypeInPackage, |
| 657 | 657 | } |
| 658 | 658 | const hashed_file = try arena.create(HashedFile); |
src/main.zig+3-3| ... | ... | @@ -4830,11 +4830,11 @@ fn fmtPathDir( |
| 4830 | 4830 | |
| 4831 | 4831 | var dir_it = iterable_dir.iterate(); |
| 4832 | 4832 | while (try dir_it.next()) |entry| { |
| 4833 | const is_dir = entry.kind == .Directory; | |
| 4833 | const is_dir = entry.kind == .directory; | |
| 4834 | 4834 | |
| 4835 | 4835 | if (is_dir and (mem.eql(u8, entry.name, "zig-cache") or mem.eql(u8, entry.name, "zig-out"))) continue; |
| 4836 | 4836 | |
| 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 | 4838 | const full_path = try fs.path.join(fmt.gpa, &[_][]const u8{ file_path, entry.name }); |
| 4839 | 4839 | defer fmt.gpa.free(full_path); |
| 4840 | 4840 | |
| ... | ... | @@ -4864,7 +4864,7 @@ fn fmtPathFile( |
| 4864 | 4864 | |
| 4865 | 4865 | const stat = try source_file.stat(); |
| 4866 | 4866 | |
| 4867 | if (stat.kind == .Directory) | |
| 4867 | if (stat.kind == .directory) | |
| 4868 | 4868 | return error.IsDir; |
| 4869 | 4869 | |
| 4870 | 4870 | const gpa = fmt.gpa; |
test/src/Cases.zig+2-2| ... | ... | @@ -349,7 +349,7 @@ fn addFromDirInner( |
| 349 | 349 | var filenames = std.ArrayList([]const u8).init(ctx.arena); |
| 350 | 350 | |
| 351 | 351 | while (try it.next()) |entry| { |
| 352 | if (entry.kind != .File) continue; | |
| 352 | if (entry.kind != .file) continue; | |
| 353 | 353 | |
| 354 | 354 | // Ignore stuff such as .swp files |
| 355 | 355 | switch (Compilation.classifyFileExt(entry.basename)) { |
| ... | ... | @@ -1039,7 +1039,7 @@ pub fn main() !void { |
| 1039 | 1039 | const stem = case_file_path[case_dirname.len + 1 .. case_file_path.len - "0.zig".len]; |
| 1040 | 1040 | var it = iterable_dir.iterate(); |
| 1041 | 1041 | while (try it.next()) |entry| { |
| 1042 | if (entry.kind != .File) continue; | |
| 1042 | if (entry.kind != .file) continue; | |
| 1043 | 1043 | if (!std.mem.startsWith(u8, entry.name, stem)) continue; |
| 1044 | 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 | 393 | while (try dir_it.next()) |entry| { |
| 394 | 394 | const full_path = try std.fs.path.join(allocator, &[_][]const u8{ full_dir_name, entry.name }); |
| 395 | 395 | switch (entry.kind) { |
| 396 | .Directory => try dir_stack.append(full_path), | |
| 397 | .File => { | |
| 396 | .directory => try dir_stack.append(full_path), | |
| 397 | .file => { | |
| 398 | 398 | const rel_path = try std.fs.path.relative(allocator, target_include_dir, full_path); |
| 399 | 399 | const max_size = 2 * 1024 * 1024 * 1024; |
| 400 | 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 | 193 | while (try dir_it.next()) |entry| { |
| 194 | 194 | const full_path = try std.fs.path.join(arena, &[_][]const u8{ full_dir_name, entry.name }); |
| 195 | 195 | switch (entry.kind) { |
| 196 | .Directory => try dir_stack.append(full_path), | |
| 197 | .File => { | |
| 196 | .directory => try dir_stack.append(full_path), | |
| 197 | .file => { | |
| 198 | 198 | const rel_path = try std.fs.path.relative(arena, target_include_dir, full_path); |
| 199 | 199 | const max_size = 2 * 1024 * 1024 * 1024; |
| 200 | 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 | 57 | defer walker.deinit(); |
| 58 | 58 | |
| 59 | 59 | walk: while (try walker.next()) |entry| { |
| 60 | if (entry.kind != .File) continue; | |
| 60 | if (entry.kind != .file) continue; | |
| 61 | 61 | if (mem.startsWith(u8, entry.basename, ".")) continue; |
| 62 | 62 | for (exempt_files) |p| { |
| 63 | 63 | if (mem.eql(u8, entry.path, p)) continue :walk; |
| ... | ... | @@ -98,7 +98,7 @@ pub fn main() !void { |
| 98 | 98 | defer walker.deinit(); |
| 99 | 99 | |
| 100 | 100 | walk: while (try walker.next()) |entry| { |
| 101 | if (entry.kind != .File) continue; | |
| 101 | if (entry.kind != .file) continue; | |
| 102 | 102 | if (mem.startsWith(u8, entry.basename, ".")) continue; |
| 103 | 103 | for (exempt_files) |p| { |
| 104 | 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 | 227 | |
| 228 | 228 | var vendor_it = extensions_dir.iterate(); |
| 229 | 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. | |
| 231 | 231 | |
| 232 | 232 | const vendor_dir = try extensions_dir.dir.openIterableDir(vendor_entry.name, .{}); |
| 233 | 233 | var ext_it = vendor_dir.iterate(); |