| author | |
| committer | |
| log | 8f5f8090c5a58c41bf0ae7cec282c0949f459d2f |
| tree | ddf8c6e5ed89fecb8448db30e0095045f45978f4 |
| parent | 41502c6aa53a3da31b276c23c4db74db7d04796b |
| parent | ba35eeb417e4d54ce4c559871b9330bc95afc053 |
| signature |
std: Snake-case some public facing enums16 files changed, 266 insertions(+), 262 deletions(-)
lib/std/Build/Cache.zig+3-3| ... | ... | @@ -408,7 +408,7 @@ pub const Manifest = struct { |
| 408 | 408 | if (self.cache.manifest_dir.createFile(&manifest_file_path, .{ |
| 409 | 409 | .read = true, |
| 410 | 410 | .truncate = false, |
| 411 | .lock = .Exclusive, | |
| 411 | .lock = .exclusive, | |
| 412 | 412 | .lock_nonblocking = self.want_shared_lock, |
| 413 | 413 | })) |manifest_file| { |
| 414 | 414 | self.manifest_file = manifest_file; |
| ... | ... | @@ -418,7 +418,7 @@ pub const Manifest = struct { |
| 418 | 418 | error.WouldBlock => { |
| 419 | 419 | self.manifest_file = try self.cache.manifest_dir.openFile(&manifest_file_path, .{ |
| 420 | 420 | .mode = .read_write, |
| 421 | .lock = .Shared, | |
| 421 | .lock = .shared, | |
| 422 | 422 | }); |
| 423 | 423 | break; |
| 424 | 424 | }, |
| ... | ... | @@ -885,7 +885,7 @@ pub const Manifest = struct { |
| 885 | 885 | // Here we intentionally have a period where the lock is released, in case there are |
| 886 | 886 | // other processes holding a shared lock. |
| 887 | 887 | manifest_file.unlock(); |
| 888 | try manifest_file.lock(.Exclusive); | |
| 888 | try manifest_file.lock(.exclusive); | |
| 889 | 889 | } |
| 890 | 890 | self.have_exclusive_lock = true; |
| 891 | 891 | return true; |
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/event/loop.zig+38-38| ... | ... | @@ -62,9 +62,9 @@ pub const Loop = struct { |
| 62 | 62 | pub const Overlapped = @TypeOf(overlapped_init); |
| 63 | 63 | |
| 64 | 64 | pub const Id = enum { |
| 65 | Basic, | |
| 66 | Stop, | |
| 67 | EventFd, | |
| 65 | basic, | |
| 66 | stop, | |
| 67 | event_fd, | |
| 68 | 68 | }; |
| 69 | 69 | |
| 70 | 70 | pub const EventFd = switch (builtin.os.tag) { |
| ... | ... | @@ -165,11 +165,11 @@ pub const Loop = struct { |
| 165 | 165 | .available_eventfd_resume_nodes = std.atomic.Stack(ResumeNode.EventFd).init(), |
| 166 | 166 | .eventfd_resume_nodes = undefined, |
| 167 | 167 | .final_resume_node = ResumeNode{ |
| 168 | .id = ResumeNode.Id.Stop, | |
| 168 | .id = .stop, | |
| 169 | 169 | .handle = undefined, |
| 170 | 170 | .overlapped = ResumeNode.overlapped_init, |
| 171 | 171 | }, |
| 172 | .fs_end_request = .{ .data = .{ .msg = .end, .finish = .NoAction } }, | |
| 172 | .fs_end_request = .{ .data = .{ .msg = .end, .finish = .no_action } }, | |
| 173 | 173 | .fs_queue = std.atomic.Queue(Request).init(), |
| 174 | 174 | .fs_thread = undefined, |
| 175 | 175 | .fs_thread_wakeup = .{}, |
| ... | ... | @@ -224,7 +224,7 @@ pub const Loop = struct { |
| 224 | 224 | eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ |
| 225 | 225 | .data = ResumeNode.EventFd{ |
| 226 | 226 | .base = ResumeNode{ |
| 227 | .id = .EventFd, | |
| 227 | .id = .event_fd, | |
| 228 | 228 | .handle = undefined, |
| 229 | 229 | .overlapped = ResumeNode.overlapped_init, |
| 230 | 230 | }, |
| ... | ... | @@ -282,7 +282,7 @@ pub const Loop = struct { |
| 282 | 282 | eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ |
| 283 | 283 | .data = ResumeNode.EventFd{ |
| 284 | 284 | .base = ResumeNode{ |
| 285 | .id = ResumeNode.Id.EventFd, | |
| 285 | .id = .event_fd, | |
| 286 | 286 | .handle = undefined, |
| 287 | 287 | .overlapped = ResumeNode.overlapped_init, |
| 288 | 288 | }, |
| ... | ... | @@ -347,7 +347,7 @@ pub const Loop = struct { |
| 347 | 347 | eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ |
| 348 | 348 | .data = ResumeNode.EventFd{ |
| 349 | 349 | .base = ResumeNode{ |
| 350 | .id = ResumeNode.Id.EventFd, | |
| 350 | .id = .event_fd, | |
| 351 | 351 | .handle = undefined, |
| 352 | 352 | .overlapped = ResumeNode.overlapped_init, |
| 353 | 353 | }, |
| ... | ... | @@ -413,7 +413,7 @@ pub const Loop = struct { |
| 413 | 413 | eventfd_node.* = std.atomic.Stack(ResumeNode.EventFd).Node{ |
| 414 | 414 | .data = ResumeNode.EventFd{ |
| 415 | 415 | .base = ResumeNode{ |
| 416 | .id = ResumeNode.Id.EventFd, | |
| 416 | .id = .event_fd, | |
| 417 | 417 | .handle = undefined, |
| 418 | 418 | .overlapped = ResumeNode.overlapped_init, |
| 419 | 419 | }, |
| ... | ... | @@ -503,7 +503,7 @@ pub const Loop = struct { |
| 503 | 503 | assert(flags & os.linux.EPOLL.ONESHOT == os.linux.EPOLL.ONESHOT); |
| 504 | 504 | var resume_node = ResumeNode.Basic{ |
| 505 | 505 | .base = ResumeNode{ |
| 506 | .id = .Basic, | |
| 506 | .id = .basic, | |
| 507 | 507 | .handle = @frame(), |
| 508 | 508 | .overlapped = ResumeNode.overlapped_init, |
| 509 | 509 | }, |
| ... | ... | @@ -590,7 +590,7 @@ pub const Loop = struct { |
| 590 | 590 | pub fn bsdWaitKev(self: *Loop, ident: usize, filter: i16, flags: u16) void { |
| 591 | 591 | var resume_node = ResumeNode.Basic{ |
| 592 | 592 | .base = ResumeNode{ |
| 593 | .id = ResumeNode.Id.Basic, | |
| 593 | .id = .basic, | |
| 594 | 594 | .handle = @frame(), |
| 595 | 595 | .overlapped = ResumeNode.overlapped_init, |
| 596 | 596 | }, |
| ... | ... | @@ -1019,7 +1019,7 @@ pub const Loop = struct { |
| 1019 | 1019 | .result = undefined, |
| 1020 | 1020 | }, |
| 1021 | 1021 | }, |
| 1022 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1022 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1023 | 1023 | }, |
| 1024 | 1024 | }; |
| 1025 | 1025 | suspend { |
| ... | ... | @@ -1041,7 +1041,7 @@ pub const Loop = struct { |
| 1041 | 1041 | .result = undefined, |
| 1042 | 1042 | }, |
| 1043 | 1043 | }, |
| 1044 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1044 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1045 | 1045 | }, |
| 1046 | 1046 | }; |
| 1047 | 1047 | suspend { |
| ... | ... | @@ -1055,7 +1055,7 @@ pub const Loop = struct { |
| 1055 | 1055 | var req_node = Request.Node{ |
| 1056 | 1056 | .data = .{ |
| 1057 | 1057 | .msg = .{ .close = .{ .fd = fd } }, |
| 1058 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1058 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1059 | 1059 | }, |
| 1060 | 1060 | }; |
| 1061 | 1061 | suspend { |
| ... | ... | @@ -1076,7 +1076,7 @@ pub const Loop = struct { |
| 1076 | 1076 | .result = undefined, |
| 1077 | 1077 | }, |
| 1078 | 1078 | }, |
| 1079 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1079 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1080 | 1080 | }, |
| 1081 | 1081 | }; |
| 1082 | 1082 | suspend { |
| ... | ... | @@ -1109,7 +1109,7 @@ pub const Loop = struct { |
| 1109 | 1109 | .result = undefined, |
| 1110 | 1110 | }, |
| 1111 | 1111 | }, |
| 1112 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1112 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1113 | 1113 | }, |
| 1114 | 1114 | }; |
| 1115 | 1115 | suspend { |
| ... | ... | @@ -1143,7 +1143,7 @@ pub const Loop = struct { |
| 1143 | 1143 | .result = undefined, |
| 1144 | 1144 | }, |
| 1145 | 1145 | }, |
| 1146 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1146 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1147 | 1147 | }, |
| 1148 | 1148 | }; |
| 1149 | 1149 | suspend { |
| ... | ... | @@ -1177,7 +1177,7 @@ pub const Loop = struct { |
| 1177 | 1177 | .result = undefined, |
| 1178 | 1178 | }, |
| 1179 | 1179 | }, |
| 1180 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1180 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1181 | 1181 | }, |
| 1182 | 1182 | }; |
| 1183 | 1183 | suspend { |
| ... | ... | @@ -1210,7 +1210,7 @@ pub const Loop = struct { |
| 1210 | 1210 | .result = undefined, |
| 1211 | 1211 | }, |
| 1212 | 1212 | }, |
| 1213 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1213 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1214 | 1214 | }, |
| 1215 | 1215 | }; |
| 1216 | 1216 | suspend { |
| ... | ... | @@ -1243,7 +1243,7 @@ pub const Loop = struct { |
| 1243 | 1243 | .result = undefined, |
| 1244 | 1244 | }, |
| 1245 | 1245 | }, |
| 1246 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1246 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1247 | 1247 | }, |
| 1248 | 1248 | }; |
| 1249 | 1249 | suspend { |
| ... | ... | @@ -1277,7 +1277,7 @@ pub const Loop = struct { |
| 1277 | 1277 | .result = undefined, |
| 1278 | 1278 | }, |
| 1279 | 1279 | }, |
| 1280 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1280 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1281 | 1281 | }, |
| 1282 | 1282 | }; |
| 1283 | 1283 | suspend { |
| ... | ... | @@ -1311,7 +1311,7 @@ pub const Loop = struct { |
| 1311 | 1311 | .result = undefined, |
| 1312 | 1312 | }, |
| 1313 | 1313 | }, |
| 1314 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1314 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1315 | 1315 | }, |
| 1316 | 1316 | }; |
| 1317 | 1317 | suspend { |
| ... | ... | @@ -1391,7 +1391,7 @@ pub const Loop = struct { |
| 1391 | 1391 | .result = undefined, |
| 1392 | 1392 | }, |
| 1393 | 1393 | }, |
| 1394 | .finish = .{ .TickNode = .{ .data = @frame() } }, | |
| 1394 | .finish = .{ .tick_node = .{ .data = @frame() } }, | |
| 1395 | 1395 | }, |
| 1396 | 1396 | }; |
| 1397 | 1397 | suspend { |
| ... | ... | @@ -1419,9 +1419,9 @@ pub const Loop = struct { |
| 1419 | 1419 | const handle = resume_node.handle; |
| 1420 | 1420 | const resume_node_id = resume_node.id; |
| 1421 | 1421 | switch (resume_node_id) { |
| 1422 | .Basic => {}, | |
| 1423 | .Stop => return, | |
| 1424 | .EventFd => { | |
| 1422 | .basic => {}, | |
| 1423 | .stop => return, | |
| 1424 | .event_fd => { | |
| 1425 | 1425 | const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); |
| 1426 | 1426 | event_fd_node.epoll_op = os.linux.EPOLL.CTL_MOD; |
| 1427 | 1427 | const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); |
| ... | ... | @@ -1429,7 +1429,7 @@ pub const Loop = struct { |
| 1429 | 1429 | }, |
| 1430 | 1430 | } |
| 1431 | 1431 | resume handle; |
| 1432 | if (resume_node_id == ResumeNode.Id.EventFd) { | |
| 1432 | if (resume_node_id == .event_fd) { | |
| 1433 | 1433 | self.finishOneEvent(); |
| 1434 | 1434 | } |
| 1435 | 1435 | } |
| ... | ... | @@ -1443,19 +1443,19 @@ pub const Loop = struct { |
| 1443 | 1443 | const handle = resume_node.handle; |
| 1444 | 1444 | const resume_node_id = resume_node.id; |
| 1445 | 1445 | switch (resume_node_id) { |
| 1446 | .Basic => { | |
| 1446 | .basic => { | |
| 1447 | 1447 | const basic_node = @fieldParentPtr(ResumeNode.Basic, "base", resume_node); |
| 1448 | 1448 | basic_node.kev = ev; |
| 1449 | 1449 | }, |
| 1450 | .Stop => return, | |
| 1451 | .EventFd => { | |
| 1450 | .stop => return, | |
| 1451 | .event_fd => { | |
| 1452 | 1452 | const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); |
| 1453 | 1453 | const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); |
| 1454 | 1454 | self.available_eventfd_resume_nodes.push(stack_node); |
| 1455 | 1455 | }, |
| 1456 | 1456 | } |
| 1457 | 1457 | resume handle; |
| 1458 | if (resume_node_id == ResumeNode.Id.EventFd) { | |
| 1458 | if (resume_node_id == .event_fd) { | |
| 1459 | 1459 | self.finishOneEvent(); |
| 1460 | 1460 | } |
| 1461 | 1461 | } |
| ... | ... | @@ -1477,9 +1477,9 @@ pub const Loop = struct { |
| 1477 | 1477 | const handle = resume_node.handle; |
| 1478 | 1478 | const resume_node_id = resume_node.id; |
| 1479 | 1479 | switch (resume_node_id) { |
| 1480 | .Basic => {}, | |
| 1481 | .Stop => return, | |
| 1482 | .EventFd => { | |
| 1480 | .basic => {}, | |
| 1481 | .stop => return, | |
| 1482 | .event_fd => { | |
| 1483 | 1483 | const event_fd_node = @fieldParentPtr(ResumeNode.EventFd, "base", resume_node); |
| 1484 | 1484 | const stack_node = @fieldParentPtr(std.atomic.Stack(ResumeNode.EventFd).Node, "data", event_fd_node); |
| 1485 | 1485 | self.available_eventfd_resume_nodes.push(stack_node); |
| ... | ... | @@ -1549,8 +1549,8 @@ pub const Loop = struct { |
| 1549 | 1549 | .close => |*msg| os.close(msg.fd), |
| 1550 | 1550 | } |
| 1551 | 1551 | switch (node.data.finish) { |
| 1552 | .TickNode => |*tick_node| self.onNextTick(tick_node), | |
| 1553 | .NoAction => {}, | |
| 1552 | .tick_node => |*tick_node| self.onNextTick(tick_node), | |
| 1553 | .no_action => {}, | |
| 1554 | 1554 | } |
| 1555 | 1555 | self.finishOneEvent(); |
| 1556 | 1556 | } |
| ... | ... | @@ -1586,8 +1586,8 @@ pub const Loop = struct { |
| 1586 | 1586 | pub const Node = std.atomic.Queue(Request).Node; |
| 1587 | 1587 | |
| 1588 | 1588 | pub const Finish = union(enum) { |
| 1589 | TickNode: Loop.NextTickNode, | |
| 1590 | NoAction, | |
| 1589 | tick_node: Loop.NextTickNode, | |
| 1590 | no_action, | |
| 1591 | 1591 | }; |
| 1592 | 1592 | |
| 1593 | 1593 | pub const Msg = union(enum) { |
lib/std/fmt.zig+18-18| ... | ... | @@ -14,15 +14,15 @@ const expectFmt = std.testing.expectFmt; |
| 14 | 14 | pub const default_max_depth = 3; |
| 15 | 15 | |
| 16 | 16 | pub const Alignment = enum { |
| 17 | Left, | |
| 18 | Center, | |
| 19 | Right, | |
| 17 | left, | |
| 18 | center, | |
| 19 | right, | |
| 20 | 20 | }; |
| 21 | 21 | |
| 22 | 22 | pub const FormatOptions = struct { |
| 23 | 23 | precision: ?usize = null, |
| 24 | 24 | width: ?usize = null, |
| 25 | alignment: Alignment = .Right, | |
| 25 | alignment: Alignment = .right, | |
| 26 | 26 | fill: u8 = ' ', |
| 27 | 27 | }; |
| 28 | 28 | |
| ... | ... | @@ -252,11 +252,11 @@ pub const Placeholder = struct { |
| 252 | 252 | else => {}, |
| 253 | 253 | } |
| 254 | 254 | break :init switch (ch) { |
| 255 | '<' => .Left, | |
| 256 | '^' => .Center, | |
| 257 | else => .Right, | |
| 255 | '<' => .left, | |
| 256 | '^' => .center, | |
| 257 | else => .right, | |
| 258 | 258 | }; |
| 259 | } else .Right; | |
| 259 | } else .right; | |
| 260 | 260 | |
| 261 | 261 | // Parse the width parameter |
| 262 | 262 | const width = comptime parser.specifier() catch |err| |
| ... | ... | @@ -1034,18 +1034,18 @@ pub fn formatBuf( |
| 1034 | 1034 | return writer.writeAll(buf); |
| 1035 | 1035 | |
| 1036 | 1036 | switch (options.alignment) { |
| 1037 | .Left => { | |
| 1037 | .left => { | |
| 1038 | 1038 | try writer.writeAll(buf); |
| 1039 | 1039 | try writer.writeByteNTimes(options.fill, padding); |
| 1040 | 1040 | }, |
| 1041 | .Center => { | |
| 1041 | .center => { | |
| 1042 | 1042 | const left_padding = padding / 2; |
| 1043 | 1043 | const right_padding = (padding + 1) / 2; |
| 1044 | 1044 | try writer.writeByteNTimes(options.fill, left_padding); |
| 1045 | 1045 | try writer.writeAll(buf); |
| 1046 | 1046 | try writer.writeByteNTimes(options.fill, right_padding); |
| 1047 | 1047 | }, |
| 1048 | .Right => { | |
| 1048 | .right => { | |
| 1049 | 1049 | try writer.writeByteNTimes(options.fill, padding); |
| 1050 | 1050 | try writer.writeAll(buf); |
| 1051 | 1051 | }, |
| ... | ... | @@ -1742,9 +1742,9 @@ pub fn Formatter(comptime format_fn: anytype) type { |
| 1742 | 1742 | /// See also `parseUnsigned`. |
| 1743 | 1743 | pub fn parseInt(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T { |
| 1744 | 1744 | if (buf.len == 0) return error.InvalidCharacter; |
| 1745 | if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .Pos); | |
| 1746 | if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .Neg); | |
| 1747 | return parseWithSign(T, buf, radix, .Pos); | |
| 1745 | if (buf[0] == '+') return parseWithSign(T, buf[1..], radix, .pos); | |
| 1746 | if (buf[0] == '-') return parseWithSign(T, buf[1..], radix, .neg); | |
| 1747 | return parseWithSign(T, buf, radix, .pos); | |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | 1750 | test "parseInt" { |
| ... | ... | @@ -1805,7 +1805,7 @@ fn parseWithSign( |
| 1805 | 1805 | comptime T: type, |
| 1806 | 1806 | buf: []const u8, |
| 1807 | 1807 | radix: u8, |
| 1808 | comptime sign: enum { Pos, Neg }, | |
| 1808 | comptime sign: enum { pos, neg }, | |
| 1809 | 1809 | ) ParseIntError!T { |
| 1810 | 1810 | if (buf.len == 0) return error.InvalidCharacter; |
| 1811 | 1811 | |
| ... | ... | @@ -1835,8 +1835,8 @@ fn parseWithSign( |
| 1835 | 1835 | } |
| 1836 | 1836 | |
| 1837 | 1837 | const add = switch (sign) { |
| 1838 | .Pos => math.add, | |
| 1839 | .Neg => math.sub, | |
| 1838 | .pos => math.add, | |
| 1839 | .neg => math.sub, | |
| 1840 | 1840 | }; |
| 1841 | 1841 | |
| 1842 | 1842 | var x: T = 0; |
| ... | ... | @@ -1866,7 +1866,7 @@ fn parseWithSign( |
| 1866 | 1866 | /// Ignores '_' character in `buf`. |
| 1867 | 1867 | /// See also `parseInt`. |
| 1868 | 1868 | pub fn parseUnsigned(comptime T: type, buf: []const u8, radix: u8) ParseIntError!T { |
| 1869 | return parseWithSign(T, buf, radix, .Pos); | |
| 1869 | return parseWithSign(T, buf, radix, .pos); | |
| 1870 | 1870 | } |
| 1871 | 1871 | |
| 1872 | 1872 | test "parseUnsigned" { |
lib/std/fs.zig+86-86| ... | ... | @@ -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, |
| ... | ... | @@ -1157,9 +1157,9 @@ pub const Dir = struct { |
| 1157 | 1157 | else |
| 1158 | 1158 | 0; |
| 1159 | 1159 | os_flags |= switch (flags.lock) { |
| 1160 | .None => @as(u32, 0), | |
| 1161 | .Shared => os.O.SHLOCK | nonblocking_lock_flag, | |
| 1162 | .Exclusive => os.O.EXLOCK | nonblocking_lock_flag, | |
| 1160 | .none => @as(u32, 0), | |
| 1161 | .shared => os.O.SHLOCK | nonblocking_lock_flag, | |
| 1162 | .exclusive => os.O.EXLOCK | nonblocking_lock_flag, | |
| 1163 | 1163 | }; |
| 1164 | 1164 | } |
| 1165 | 1165 | if (@hasDecl(os.O, "LARGEFILE")) { |
| ... | ... | @@ -1182,13 +1182,13 @@ pub const Dir = struct { |
| 1182 | 1182 | // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block |
| 1183 | 1183 | // since it is not compiltime-known and we need to avoid undefined symbol in Wasm. |
| 1184 | 1184 | if (builtin.target.os.tag != .wasi) { |
| 1185 | if (!has_flock_open_flags and flags.lock != .None) { | |
| 1185 | if (!has_flock_open_flags and flags.lock != .none) { | |
| 1186 | 1186 | // TODO: integrate async I/O |
| 1187 | 1187 | const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0); |
| 1188 | 1188 | try os.flock(fd, switch (flags.lock) { |
| 1189 | .None => unreachable, | |
| 1190 | .Shared => os.LOCK.SH | lock_nonblocking, | |
| 1191 | .Exclusive => os.LOCK.EX | lock_nonblocking, | |
| 1189 | .none => unreachable, | |
| 1190 | .shared => os.LOCK.SH | lock_nonblocking, | |
| 1191 | .exclusive => os.LOCK.EX | lock_nonblocking, | |
| 1192 | 1192 | }); |
| 1193 | 1193 | } |
| 1194 | 1194 | } |
| ... | ... | @@ -1241,9 +1241,9 @@ pub const Dir = struct { |
| 1241 | 1241 | const range_off: w.LARGE_INTEGER = 0; |
| 1242 | 1242 | const range_len: w.LARGE_INTEGER = 1; |
| 1243 | 1243 | const exclusive = switch (flags.lock) { |
| 1244 | .None => return file, | |
| 1245 | .Shared => false, | |
| 1246 | .Exclusive => true, | |
| 1244 | .none => return file, | |
| 1245 | .shared => false, | |
| 1246 | .exclusive => true, | |
| 1247 | 1247 | }; |
| 1248 | 1248 | try w.LockFile( |
| 1249 | 1249 | file.handle, |
| ... | ... | @@ -1320,9 +1320,9 @@ pub const Dir = struct { |
| 1320 | 1320 | else |
| 1321 | 1321 | 0; |
| 1322 | 1322 | const lock_flag: u32 = if (has_flock_open_flags) switch (flags.lock) { |
| 1323 | .None => @as(u32, 0), | |
| 1324 | .Shared => os.O.SHLOCK | nonblocking_lock_flag, | |
| 1325 | .Exclusive => os.O.EXLOCK | nonblocking_lock_flag, | |
| 1323 | .none => @as(u32, 0), | |
| 1324 | .shared => os.O.SHLOCK | nonblocking_lock_flag, | |
| 1325 | .exclusive => os.O.EXLOCK | nonblocking_lock_flag, | |
| 1326 | 1326 | } else 0; |
| 1327 | 1327 | |
| 1328 | 1328 | const O_LARGEFILE = if (@hasDecl(os.O, "LARGEFILE")) os.O.LARGEFILE else 0; |
| ... | ... | @@ -1339,13 +1339,13 @@ pub const Dir = struct { |
| 1339 | 1339 | // WASI doesn't have os.flock so we intetinally check OS prior to the inner if block |
| 1340 | 1340 | // since it is not compiltime-known and we need to avoid undefined symbol in Wasm. |
| 1341 | 1341 | if (builtin.target.os.tag != .wasi) { |
| 1342 | if (!has_flock_open_flags and flags.lock != .None) { | |
| 1342 | if (!has_flock_open_flags and flags.lock != .none) { | |
| 1343 | 1343 | // TODO: integrate async I/O |
| 1344 | 1344 | const lock_nonblocking = if (flags.lock_nonblocking) os.LOCK.NB else @as(i32, 0); |
| 1345 | 1345 | try os.flock(fd, switch (flags.lock) { |
| 1346 | .None => unreachable, | |
| 1347 | .Shared => os.LOCK.SH | lock_nonblocking, | |
| 1348 | .Exclusive => os.LOCK.EX | lock_nonblocking, | |
| 1346 | .none => unreachable, | |
| 1347 | .shared => os.LOCK.SH | lock_nonblocking, | |
| 1348 | .exclusive => os.LOCK.EX | lock_nonblocking, | |
| 1349 | 1349 | }); |
| 1350 | 1350 | } |
| 1351 | 1351 | } |
| ... | ... | @@ -1402,9 +1402,9 @@ pub const Dir = struct { |
| 1402 | 1402 | const range_off: w.LARGE_INTEGER = 0; |
| 1403 | 1403 | const range_len: w.LARGE_INTEGER = 1; |
| 1404 | 1404 | const exclusive = switch (flags.lock) { |
| 1405 | .None => return file, | |
| 1406 | .Shared => false, | |
| 1407 | .Exclusive => true, | |
| 1405 | .none => return file, | |
| 1406 | .shared => false, | |
| 1407 | .exclusive => true, | |
| 1408 | 1408 | }; |
| 1409 | 1409 | try w.LockFile( |
| 1410 | 1410 | file.handle, |
| ... | ... | @@ -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+79-75| ... | ... | @@ -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 |
| ... | ... | @@ -81,7 +81,11 @@ pub const File = struct { |
| 81 | 81 | read_write, |
| 82 | 82 | }; |
| 83 | 83 | |
| 84 | pub const Lock = enum { None, Shared, Exclusive }; | |
| 84 | pub const Lock = enum { | |
| 85 | none, | |
| 86 | shared, | |
| 87 | exclusive, | |
| 88 | }; | |
| 85 | 89 | |
| 86 | 90 | pub const OpenFlags = struct { |
| 87 | 91 | mode: OpenMode = .read_only, |
| ... | ... | @@ -110,7 +114,7 @@ pub const File = struct { |
| 110 | 114 | /// * Windows |
| 111 | 115 | /// |
| 112 | 116 | /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt |
| 113 | lock: Lock = .None, | |
| 117 | lock: Lock = .none, | |
| 114 | 118 | |
| 115 | 119 | /// Sets whether or not to wait until the file is locked to return. If set to true, |
| 116 | 120 | /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file |
| ... | ... | @@ -174,7 +178,7 @@ pub const File = struct { |
| 174 | 178 | /// * Windows |
| 175 | 179 | /// |
| 176 | 180 | /// [1]: https://www.kernel.org/doc/Documentation/filesystems/mandatory-locking.txt |
| 177 | lock: Lock = .None, | |
| 181 | lock: Lock = .none, | |
| 178 | 182 | |
| 179 | 183 | /// Sets whether or not to wait until the file is locked to return. If set to true, |
| 180 | 184 | /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file |
| ... | ... | @@ -329,32 +333,32 @@ pub const File = struct { |
| 329 | 333 | const mtime = st.mtime(); |
| 330 | 334 | const ctime = st.ctime(); |
| 331 | 335 | const kind: Kind = if (builtin.os.tag == .wasi and !builtin.link_libc) switch (st.filetype) { |
| 332 | .BLOCK_DEVICE => Kind.BlockDevice, | |
| 333 | .CHARACTER_DEVICE => Kind.CharacterDevice, | |
| 334 | .DIRECTORY => Kind.Directory, | |
| 335 | .SYMBOLIC_LINK => Kind.SymLink, | |
| 336 | .REGULAR_FILE => Kind.File, | |
| 337 | .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket, | |
| 338 | else => Kind.Unknown, | |
| 336 | .BLOCK_DEVICE => .block_device, | |
| 337 | .CHARACTER_DEVICE => .character_device, | |
| 338 | .DIRECTORY => .directory, | |
| 339 | .SYMBOLIC_LINK => .sym_link, | |
| 340 | .REGULAR_FILE => .file, | |
| 341 | .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, | |
| 342 | else => .unknown, | |
| 339 | 343 | } else blk: { |
| 340 | 344 | const m = st.mode & os.S.IFMT; |
| 341 | 345 | switch (m) { |
| 342 | os.S.IFBLK => break :blk Kind.BlockDevice, | |
| 343 | os.S.IFCHR => break :blk Kind.CharacterDevice, | |
| 344 | os.S.IFDIR => break :blk Kind.Directory, | |
| 345 | os.S.IFIFO => break :blk Kind.NamedPipe, | |
| 346 | os.S.IFLNK => break :blk Kind.SymLink, | |
| 347 | os.S.IFREG => break :blk Kind.File, | |
| 348 | os.S.IFSOCK => break :blk Kind.UnixDomainSocket, | |
| 346 | os.S.IFBLK => break :blk .block_device, | |
| 347 | os.S.IFCHR => break :blk .character_device, | |
| 348 | os.S.IFDIR => break :blk .directory, | |
| 349 | os.S.IFIFO => break :blk .named_pipe, | |
| 350 | os.S.IFLNK => break :blk .sym_link, | |
| 351 | os.S.IFREG => break :blk .file, | |
| 352 | os.S.IFSOCK => break :blk .unix_domain_socket, | |
| 349 | 353 | else => {}, |
| 350 | 354 | } |
| 351 | 355 | if (builtin.os.tag == .solaris) switch (m) { |
| 352 | os.S.IFDOOR => break :blk Kind.Door, | |
| 353 | os.S.IFPORT => break :blk Kind.EventPort, | |
| 356 | os.S.IFDOOR => break :blk .door, | |
| 357 | os.S.IFPORT => break :blk .event_port, | |
| 354 | 358 | else => {}, |
| 355 | 359 | }; |
| 356 | 360 | |
| 357 | break :blk .Unknown; | |
| 361 | break :blk .unknown; | |
| 358 | 362 | }; |
| 359 | 363 | |
| 360 | 364 | return Stat{ |
| ... | ... | @@ -391,7 +395,7 @@ pub const File = struct { |
| 391 | 395 | .inode = info.InternalInformation.IndexNumber, |
| 392 | 396 | .size = @bitCast(u64, info.StandardInformation.EndOfFile), |
| 393 | 397 | .mode = 0, |
| 394 | .kind = if (info.StandardInformation.Directory == 0) .File else .Directory, | |
| 398 | .kind = if (info.StandardInformation.Directory == 0) .file else .directory, | |
| 395 | 399 | .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime), |
| 396 | 400 | .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime), |
| 397 | 401 | .ctime = windows.fromSysTime(info.BasicInformation.CreationTime), |
| ... | ... | @@ -609,7 +613,7 @@ pub const File = struct { |
| 609 | 613 | } |
| 610 | 614 | |
| 611 | 615 | /// Returns the `Kind` of file. |
| 612 | /// On Windows, can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown` | |
| 616 | /// On Windows, can only return: `.file`, `.directory`, `.sym_link` or `.unknown` | |
| 613 | 617 | pub fn kind(self: Self) Kind { |
| 614 | 618 | return self.inner.kind(); |
| 615 | 619 | } |
| ... | ... | @@ -652,35 +656,35 @@ pub const File = struct { |
| 652 | 656 | /// Returns the `Kind` of the file |
| 653 | 657 | pub fn kind(self: Self) Kind { |
| 654 | 658 | if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) { |
| 655 | .BLOCK_DEVICE => Kind.BlockDevice, | |
| 656 | .CHARACTER_DEVICE => Kind.CharacterDevice, | |
| 657 | .DIRECTORY => Kind.Directory, | |
| 658 | .SYMBOLIC_LINK => Kind.SymLink, | |
| 659 | .REGULAR_FILE => Kind.File, | |
| 660 | .SOCKET_STREAM, .SOCKET_DGRAM => Kind.UnixDomainSocket, | |
| 661 | else => Kind.Unknown, | |
| 659 | .BLOCK_DEVICE => .block_device, | |
| 660 | .CHARACTER_DEVICE => .character_device, | |
| 661 | .DIRECTORY => .directory, | |
| 662 | .SYMBOLIC_LINK => .sym_link, | |
| 663 | .REGULAR_FILE => .file, | |
| 664 | .SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket, | |
| 665 | else => .unknown, | |
| 662 | 666 | }; |
| 663 | 667 | |
| 664 | 668 | const m = self.stat.mode & os.S.IFMT; |
| 665 | 669 | |
| 666 | 670 | switch (m) { |
| 667 | os.S.IFBLK => return Kind.BlockDevice, | |
| 668 | os.S.IFCHR => return Kind.CharacterDevice, | |
| 669 | os.S.IFDIR => return Kind.Directory, | |
| 670 | os.S.IFIFO => return Kind.NamedPipe, | |
| 671 | os.S.IFLNK => return Kind.SymLink, | |
| 672 | os.S.IFREG => return Kind.File, | |
| 673 | os.S.IFSOCK => return Kind.UnixDomainSocket, | |
| 671 | os.S.IFBLK => return .block_device, | |
| 672 | os.S.IFCHR => return .character_device, | |
| 673 | os.S.IFDIR => return .directory, | |
| 674 | os.S.IFIFO => return .named_pipe, | |
| 675 | os.S.IFLNK => return .sym_link, | |
| 676 | os.S.IFREG => return .file, | |
| 677 | os.S.IFSOCK => return .unix_domain_socket, | |
| 674 | 678 | else => {}, |
| 675 | 679 | } |
| 676 | 680 | |
| 677 | 681 | if (builtin.os.tag == .solaris) switch (m) { |
| 678 | os.S.IFDOOR => return Kind.Door, | |
| 679 | os.S.IFPORT => return Kind.EventPort, | |
| 682 | os.S.IFDOOR => return .door, | |
| 683 | os.S.IFPORT => return .event_port, | |
| 680 | 684 | else => {}, |
| 681 | 685 | }; |
| 682 | 686 | |
| 683 | return .Unknown; | |
| 687 | return .unknown; | |
| 684 | 688 | } |
| 685 | 689 | |
| 686 | 690 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| ... | ... | @@ -738,17 +742,17 @@ pub const File = struct { |
| 738 | 742 | const m = self.statx.mode & os.S.IFMT; |
| 739 | 743 | |
| 740 | 744 | switch (m) { |
| 741 | os.S.IFBLK => return Kind.BlockDevice, | |
| 742 | os.S.IFCHR => return Kind.CharacterDevice, | |
| 743 | os.S.IFDIR => return Kind.Directory, | |
| 744 | os.S.IFIFO => return Kind.NamedPipe, | |
| 745 | os.S.IFLNK => return Kind.SymLink, | |
| 746 | os.S.IFREG => return Kind.File, | |
| 747 | os.S.IFSOCK => return Kind.UnixDomainSocket, | |
| 745 | os.S.IFBLK => return .block_device, | |
| 746 | os.S.IFCHR => return .character_device, | |
| 747 | os.S.IFDIR => return .directory, | |
| 748 | os.S.IFIFO => return .named_pipe, | |
| 749 | os.S.IFLNK => return .sym_link, | |
| 750 | os.S.IFREG => return .file, | |
| 751 | os.S.IFSOCK => return .unix_domain_socket, | |
| 748 | 752 | else => {}, |
| 749 | 753 | } |
| 750 | 754 | |
| 751 | return .Unknown; | |
| 755 | return .unknown; | |
| 752 | 756 | } |
| 753 | 757 | |
| 754 | 758 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| ... | ... | @@ -790,18 +794,18 @@ pub const File = struct { |
| 790 | 794 | } |
| 791 | 795 | |
| 792 | 796 | /// Returns the `Kind` of the file. |
| 793 | /// Can only return: `.File`, `.Directory`, `.SymLink` or `.Unknown` | |
| 797 | /// Can only return: `.file`, `.directory`, `.sym_link` or `.unknown` | |
| 794 | 798 | pub fn kind(self: Self) Kind { |
| 795 | 799 | if (self.attributes & windows.FILE_ATTRIBUTE_REPARSE_POINT != 0) { |
| 796 | 800 | if (self.reparse_tag & 0x20000000 != 0) { |
| 797 | return .SymLink; | |
| 801 | return .sym_link; | |
| 798 | 802 | } |
| 799 | 803 | } else if (self.attributes & windows.FILE_ATTRIBUTE_DIRECTORY != 0) { |
| 800 | return .Directory; | |
| 804 | return .directory; | |
| 801 | 805 | } else { |
| 802 | return .File; | |
| 806 | return .file; | |
| 803 | 807 | } |
| 804 | return .Unknown; | |
| 808 | return .unknown; | |
| 805 | 809 | } |
| 806 | 810 | |
| 807 | 811 | /// Returns the last time the file was accessed in nanoseconds since UTC 1970-01-01 |
| ... | ... | @@ -1465,9 +1469,9 @@ pub const File = struct { |
| 1465 | 1469 | if (is_windows) { |
| 1466 | 1470 | var io_status_block: windows.IO_STATUS_BLOCK = undefined; |
| 1467 | 1471 | const exclusive = switch (l) { |
| 1468 | .None => return, | |
| 1469 | .Shared => false, | |
| 1470 | .Exclusive => true, | |
| 1472 | .none => return, | |
| 1473 | .shared => false, | |
| 1474 | .exclusive => true, | |
| 1471 | 1475 | }; |
| 1472 | 1476 | return windows.LockFile( |
| 1473 | 1477 | file.handle, |
| ... | ... | @@ -1486,9 +1490,9 @@ pub const File = struct { |
| 1486 | 1490 | }; |
| 1487 | 1491 | } else { |
| 1488 | 1492 | return os.flock(file.handle, switch (l) { |
| 1489 | .None => os.LOCK.UN, | |
| 1490 | .Shared => os.LOCK.SH, | |
| 1491 | .Exclusive => os.LOCK.EX, | |
| 1493 | .none => os.LOCK.UN, | |
| 1494 | .shared => os.LOCK.SH, | |
| 1495 | .exclusive => os.LOCK.EX, | |
| 1492 | 1496 | }) catch |err| switch (err) { |
| 1493 | 1497 | error.WouldBlock => unreachable, // non-blocking=false |
| 1494 | 1498 | else => |e| return e, |
| ... | ... | @@ -1532,9 +1536,9 @@ pub const File = struct { |
| 1532 | 1536 | if (is_windows) { |
| 1533 | 1537 | var io_status_block: windows.IO_STATUS_BLOCK = undefined; |
| 1534 | 1538 | const exclusive = switch (l) { |
| 1535 | .None => return, | |
| 1536 | .Shared => false, | |
| 1537 | .Exclusive => true, | |
| 1539 | .none => return, | |
| 1540 | .shared => false, | |
| 1541 | .exclusive => true, | |
| 1538 | 1542 | }; |
| 1539 | 1543 | windows.LockFile( |
| 1540 | 1544 | file.handle, |
| ... | ... | @@ -1553,9 +1557,9 @@ pub const File = struct { |
| 1553 | 1557 | }; |
| 1554 | 1558 | } else { |
| 1555 | 1559 | os.flock(file.handle, switch (l) { |
| 1556 | .None => os.LOCK.UN, | |
| 1557 | .Shared => os.LOCK.SH | os.LOCK.NB, | |
| 1558 | .Exclusive => os.LOCK.EX | os.LOCK.NB, | |
| 1560 | .none => os.LOCK.UN, | |
| 1561 | .shared => os.LOCK.SH | os.LOCK.NB, | |
| 1562 | .exclusive => os.LOCK.EX | os.LOCK.NB, | |
| 1559 | 1563 | }) catch |err| switch (err) { |
| 1560 | 1564 | error.WouldBlock => return false, |
| 1561 | 1565 | else => |e| return e, |
lib/std/fs/test.zig+21-21| ... | ... | @@ -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 | } |
| ... | ... | @@ -336,7 +336,7 @@ test "Dir.realpath smoke test" { |
| 336 | 336 | var tmp_dir = tmpDir(.{}); |
| 337 | 337 | defer tmp_dir.cleanup(); |
| 338 | 338 | |
| 339 | var file = try tmp_dir.dir.createFile("test_file", .{ .lock = File.Lock.Shared }); | |
| 339 | var file = try tmp_dir.dir.createFile("test_file", .{ .lock = .shared }); | |
| 340 | 340 | // We need to close the file immediately as otherwise on Windows we'll end up |
| 341 | 341 | // with a sharing violation. |
| 342 | 342 | file.close(); |
| ... | ... | @@ -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 |
| ... | ... | @@ -1035,10 +1035,10 @@ test "open file with exclusive nonblocking lock twice" { |
| 1035 | 1035 | var tmp = tmpDir(.{}); |
| 1036 | 1036 | defer tmp.cleanup(); |
| 1037 | 1037 | |
| 1038 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); | |
| 1038 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1039 | 1039 | defer file1.close(); |
| 1040 | 1040 | |
| 1041 | const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); | |
| 1041 | const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1042 | 1042 | try testing.expectError(error.WouldBlock, file2); |
| 1043 | 1043 | } |
| 1044 | 1044 | |
| ... | ... | @@ -1050,10 +1050,10 @@ test "open file with shared and exclusive nonblocking lock" { |
| 1050 | 1050 | var tmp = tmpDir(.{}); |
| 1051 | 1051 | defer tmp.cleanup(); |
| 1052 | 1052 | |
| 1053 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true }); | |
| 1053 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1054 | 1054 | defer file1.close(); |
| 1055 | 1055 | |
| 1056 | const file2 = tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); | |
| 1056 | const file2 = tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1057 | 1057 | try testing.expectError(error.WouldBlock, file2); |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| ... | ... | @@ -1065,10 +1065,10 @@ test "open file with exclusive and shared nonblocking lock" { |
| 1065 | 1065 | var tmp = tmpDir(.{}); |
| 1066 | 1066 | defer tmp.cleanup(); |
| 1067 | 1067 | |
| 1068 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .Exclusive, .lock_nonblocking = true }); | |
| 1068 | const file1 = try tmp.dir.createFile(filename, .{ .lock = .exclusive, .lock_nonblocking = true }); | |
| 1069 | 1069 | defer file1.close(); |
| 1070 | 1070 | |
| 1071 | const file2 = tmp.dir.createFile(filename, .{ .lock = .Shared, .lock_nonblocking = true }); | |
| 1071 | const file2 = tmp.dir.createFile(filename, .{ .lock = .shared, .lock_nonblocking = true }); | |
| 1072 | 1072 | try testing.expectError(error.WouldBlock, file2); |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| ... | ... | @@ -1085,13 +1085,13 @@ test "open file with exclusive lock twice, make sure second lock waits" { |
| 1085 | 1085 | var tmp = tmpDir(.{}); |
| 1086 | 1086 | defer tmp.cleanup(); |
| 1087 | 1087 | |
| 1088 | const file = try tmp.dir.createFile(filename, .{ .lock = .Exclusive }); | |
| 1088 | const file = try tmp.dir.createFile(filename, .{ .lock = .exclusive }); | |
| 1089 | 1089 | errdefer file.close(); |
| 1090 | 1090 | |
| 1091 | 1091 | const S = struct { |
| 1092 | 1092 | fn checkFn(dir: *fs.Dir, started: *std.Thread.ResetEvent, locked: *std.Thread.ResetEvent) !void { |
| 1093 | 1093 | started.set(); |
| 1094 | const file1 = try dir.createFile(filename, .{ .lock = .Exclusive }); | |
| 1094 | const file1 = try dir.createFile(filename, .{ .lock = .exclusive }); | |
| 1095 | 1095 | |
| 1096 | 1096 | locked.set(); |
| 1097 | 1097 | file1.close(); |
| ... | ... | @@ -1138,12 +1138,12 @@ test "open file with exclusive nonblocking lock twice (absolute paths)" { |
| 1138 | 1138 | defer gpa.free(filename); |
| 1139 | 1139 | |
| 1140 | 1140 | const file1 = try fs.createFileAbsolute(filename, .{ |
| 1141 | .lock = .Exclusive, | |
| 1141 | .lock = .exclusive, | |
| 1142 | 1142 | .lock_nonblocking = true, |
| 1143 | 1143 | }); |
| 1144 | 1144 | |
| 1145 | 1145 | const file2 = fs.createFileAbsolute(filename, .{ |
| 1146 | .lock = .Exclusive, | |
| 1146 | .lock = .exclusive, | |
| 1147 | 1147 | .lock_nonblocking = true, |
| 1148 | 1148 | }); |
| 1149 | 1149 | file1.close(); |
| ... | ... | @@ -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/Module.zig+4-4| ... | ... | @@ -3618,7 +3618,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void { |
| 3618 | 3618 | file.sub_file_path, want_local_cache, &digest, |
| 3619 | 3619 | }); |
| 3620 | 3620 | |
| 3621 | break :lock .Shared; | |
| 3621 | break :lock .shared; | |
| 3622 | 3622 | }, |
| 3623 | 3623 | .parse_failure, .astgen_failure, .success_zir => lock: { |
| 3624 | 3624 | const unchanged_metadata = |
| ... | ... | @@ -3633,7 +3633,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void { |
| 3633 | 3633 | |
| 3634 | 3634 | log.debug("metadata changed: {s}", .{file.sub_file_path}); |
| 3635 | 3635 | |
| 3636 | break :lock .Exclusive; | |
| 3636 | break :lock .exclusive; | |
| 3637 | 3637 | }, |
| 3638 | 3638 | }; |
| 3639 | 3639 | |
| ... | ... | @@ -3715,11 +3715,11 @@ pub fn astGenFile(mod: *Module, file: *File) !void { |
| 3715 | 3715 | } |
| 3716 | 3716 | |
| 3717 | 3717 | // If we already have the exclusive lock then it is our job to update. |
| 3718 | if (builtin.os.tag == .wasi or lock == .Exclusive) break; | |
| 3718 | if (builtin.os.tag == .wasi or lock == .exclusive) break; | |
| 3719 | 3719 | // Otherwise, unlock to give someone a chance to get the exclusive lock |
| 3720 | 3720 | // and then upgrade to an exclusive lock. |
| 3721 | 3721 | cache_file.unlock(); |
| 3722 | lock = .Exclusive; | |
| 3722 | lock = .exclusive; | |
| 3723 | 3723 | try cache_file.lock(lock); |
| 3724 | 3724 | } |
| 3725 | 3725 |
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(); |