| author | |
| committer | |
| log | e357550610aef476390ed7191eeaf7597a8e9d53 |
| tree | 73b53ef2bd5cfb0fc185fc15d6ddcedd65e83eae |
| parent | 519ba9bb654a4d5caf7440160f018b7a3ae1e95a |
11 files changed, 66 insertions(+), 57 deletions(-)
lib/std/Build/Step/InstallDir.zig+1-1| ... | ... | @@ -69,7 +69,7 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 69 | 69 | const dest_prefix = dest_builder.getInstallPath(self.options.install_dir, self.options.install_subdir); |
| 70 | 70 | const src_builder = self.step.owner; |
| 71 | 71 | const src_dir_path = self.options.source_dir.getPath2(src_builder, step); |
| 72 | var src_dir = src_builder.build_root.handle.openIterableDir(src_dir_path, .{}) catch |err| { | |
| 72 | var src_dir = src_builder.build_root.handle.openDir(src_dir_path, .{ .iterate = true }) catch |err| { | |
| 73 | 73 | return step.fail("unable to open source directory '{}{s}': {s}", .{ |
| 74 | 74 | src_builder.build_root, src_dir_path, @errorName(err), |
| 75 | 75 | }); |
lib/std/child_process.zig+2-1| ... | ... | @@ -976,7 +976,8 @@ fn windowsCreateProcessPathExt( |
| 976 | 976 | defer dir_buf.shrinkRetainingCapacity(dir_path_len); |
| 977 | 977 | const dir_path_z = dir_buf.items[0 .. dir_buf.items.len - 1 :0]; |
| 978 | 978 | const prefixed_path = try windows.wToPrefixedFileW(null, dir_path_z); |
| 979 | break :dir fs.cwd().openDirW(prefixed_path.span().ptr, .{}, true) catch return error.FileNotFound; | |
| 979 | break :dir fs.cwd().openDirW(prefixed_path.span().ptr, .{ .iterate = true }) catch | |
| 980 | return error.FileNotFound; | |
| 980 | 981 | }; |
| 981 | 982 | defer dir.close(); |
| 982 | 983 |
lib/std/crypto/Certificate/Bundle.zig+4-4| ... | ... | @@ -160,7 +160,7 @@ pub fn addCertsFromDirPath( |
| 160 | 160 | dir: fs.Dir, |
| 161 | 161 | sub_dir_path: []const u8, |
| 162 | 162 | ) AddCertsFromDirPathError!void { |
| 163 | var iterable_dir = try dir.openIterableDir(sub_dir_path, .{}); | |
| 163 | var iterable_dir = try dir.openDir(sub_dir_path, .{ .iterate = true }); | |
| 164 | 164 | defer iterable_dir.close(); |
| 165 | 165 | return addCertsFromDir(cb, gpa, iterable_dir); |
| 166 | 166 | } |
| ... | ... | @@ -171,14 +171,14 @@ pub fn addCertsFromDirPathAbsolute( |
| 171 | 171 | abs_dir_path: []const u8, |
| 172 | 172 | ) AddCertsFromDirPathError!void { |
| 173 | 173 | assert(fs.path.isAbsolute(abs_dir_path)); |
| 174 | var iterable_dir = try fs.openIterableDirAbsolute(abs_dir_path, .{}); | |
| 174 | var iterable_dir = try fs.openDirAbsolute(abs_dir_path, .{ .iterate = true }); | |
| 175 | 175 | defer iterable_dir.close(); |
| 176 | 176 | return addCertsFromDir(cb, gpa, iterable_dir); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | pub const AddCertsFromDirError = AddCertsFromFilePathError; |
| 180 | 180 | |
| 181 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.IterableDir) AddCertsFromDirError!void { | |
| 181 | pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.Dir) AddCertsFromDirError!void { | |
| 182 | 182 | var it = iterable_dir.iterate(); |
| 183 | 183 | while (try it.next()) |entry| { |
| 184 | 184 | switch (entry.kind) { |
| ... | ... | @@ -186,7 +186,7 @@ pub fn addCertsFromDir(cb: *Bundle, gpa: Allocator, iterable_dir: fs.IterableDir |
| 186 | 186 | else => continue, |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | try addCertsFromFilePath(cb, gpa, iterable_dir.dir, entry.name); | |
| 189 | try addCertsFromFilePath(cb, gpa, iterable_dir, entry.name); | |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 |
lib/std/fs.zig+5-5| ... | ... | @@ -1653,12 +1653,12 @@ pub const Dir = struct { |
| 1653 | 1653 | pub fn openDir(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir { |
| 1654 | 1654 | if (builtin.os.tag == .windows) { |
| 1655 | 1655 | const sub_path_w = try os.windows.sliceToPrefixedFileW(self.fd, sub_path); |
| 1656 | return .{ .dir = try self.openDirW(sub_path_w.span().ptr, args) }; | |
| 1656 | return self.openDirW(sub_path_w.span().ptr, args); | |
| 1657 | 1657 | } else if (builtin.os.tag == .wasi and !builtin.link_libc) { |
| 1658 | return .{ .dir = try self.openDirWasi(sub_path, args) }; | |
| 1658 | return self.openDirWasi(sub_path, args); | |
| 1659 | 1659 | } else { |
| 1660 | 1660 | const sub_path_c = try os.toPosixPath(sub_path); |
| 1661 | return .{ .dir = try self.openDirZ(&sub_path_c, args) }; | |
| 1661 | return self.openDirZ(&sub_path_c, args); | |
| 1662 | 1662 | } |
| 1663 | 1663 | } |
| 1664 | 1664 | |
| ... | ... | @@ -2784,12 +2784,12 @@ pub fn openDirAbsolute(absolute_path: []const u8, flags: Dir.OpenDirOptions) Fil |
| 2784 | 2784 | /// Same as `openDirAbsolute` but the path parameter is null-terminated. |
| 2785 | 2785 | pub fn openDirAbsoluteZ(absolute_path_c: [*:0]const u8, flags: Dir.OpenDirOptions) File.OpenError!Dir { |
| 2786 | 2786 | assert(path.isAbsoluteZ(absolute_path_c)); |
| 2787 | return cwd().openDirZ(absolute_path_c, flags, false); | |
| 2787 | return cwd().openDirZ(absolute_path_c, flags); | |
| 2788 | 2788 | } |
| 2789 | 2789 | /// Same as `openDirAbsolute` but the path parameter is null-terminated. |
| 2790 | 2790 | pub fn openDirAbsoluteW(absolute_path_c: [*:0]const u16, flags: Dir.OpenDirOptions) File.OpenError!Dir { |
| 2791 | 2791 | assert(path.isAbsoluteWindowsW(absolute_path_c)); |
| 2792 | return cwd().openDirW(absolute_path_c, flags, false); | |
| 2792 | return cwd().openDirW(absolute_path_c, flags); | |
| 2793 | 2793 | } |
| 2794 | 2794 | |
| 2795 | 2795 | /// Opens a file for reading or writing, without attempting to create a new file, based on an absolute path. |
lib/std/fs/test.zig+18-20| ... | ... | @@ -72,9 +72,8 @@ const PathType = enum { |
| 72 | 72 | const TestContext = struct { |
| 73 | 73 | path_type: PathType, |
| 74 | 74 | arena: ArenaAllocator, |
| 75 | tmp: testing.TmpIterableDir, | |
| 75 | tmp: testing.TmpDir, | |
| 76 | 76 | dir: std.fs.Dir, |
| 77 | iterable_dir: std.fs.Dir, | |
| 78 | 77 | transform_fn: *const PathType.TransformFn, |
| 79 | 78 | |
| 80 | 79 | pub fn init(path_type: PathType, allocator: mem.Allocator, transform_fn: *const PathType.TransformFn) TestContext { |
| ... | ... | @@ -83,8 +82,7 @@ const TestContext = struct { |
| 83 | 82 | .path_type = path_type, |
| 84 | 83 | .arena = ArenaAllocator.init(allocator), |
| 85 | 84 | .tmp = tmp, |
| 86 | .dir = tmp.iterable_dir.dir, | |
| 87 | .iterable_dir = tmp.iterable_dir, | |
| 85 | .dir = tmp.dir, | |
| 88 | 86 | .transform_fn = transform_fn, |
| 89 | 87 | }; |
| 90 | 88 | } |
| ... | ... | @@ -359,7 +357,7 @@ test "Dir.Iterator many entries" { |
| 359 | 357 | var buf: [4]u8 = undefined; // Enough to store "1024". |
| 360 | 358 | while (i < num) : (i += 1) { |
| 361 | 359 | const name = try std.fmt.bufPrint(&buf, "{}", .{i}); |
| 362 | const file = try tmp_dir.iterable_dir.dir.createFile(name, .{}); | |
| 360 | const file = try tmp_dir.dir.createFile(name, .{}); | |
| 363 | 361 | file.close(); |
| 364 | 362 | } |
| 365 | 363 | |
| ... | ... | @@ -370,7 +368,7 @@ test "Dir.Iterator many entries" { |
| 370 | 368 | var entries = std.ArrayList(Dir.Entry).init(allocator); |
| 371 | 369 | |
| 372 | 370 | // Create iterator. |
| 373 | var iter = tmp_dir.iterable_dir.iterate(); | |
| 371 | var iter = tmp_dir.dir.iterate(); | |
| 374 | 372 | while (try iter.next()) |entry| { |
| 375 | 373 | // We cannot just store `entry` as on Windows, we're re-using the name buffer |
| 376 | 374 | // which means we'll actually share the `name` pointer between entries! |
| ... | ... | @@ -423,17 +421,17 @@ test "Dir.Iterator reset" { |
| 423 | 421 | defer tmp_dir.cleanup(); |
| 424 | 422 | |
| 425 | 423 | // First, create a couple of entries to iterate over. |
| 426 | const file = try tmp_dir.iterable_dir.dir.createFile("some_file", .{}); | |
| 424 | const file = try tmp_dir.dir.createFile("some_file", .{}); | |
| 427 | 425 | file.close(); |
| 428 | 426 | |
| 429 | try tmp_dir.iterable_dir.dir.makeDir("some_dir"); | |
| 427 | try tmp_dir.dir.makeDir("some_dir"); | |
| 430 | 428 | |
| 431 | 429 | var arena = ArenaAllocator.init(testing.allocator); |
| 432 | 430 | defer arena.deinit(); |
| 433 | 431 | const allocator = arena.allocator(); |
| 434 | 432 | |
| 435 | 433 | // Create iterator. |
| 436 | var iter = tmp_dir.iterable_dir.iterate(); | |
| 434 | var iter = tmp_dir.dir.iterate(); | |
| 437 | 435 | |
| 438 | 436 | var i: u8 = 0; |
| 439 | 437 | while (i < 2) : (i += 1) { |
| ... | ... | @@ -459,10 +457,10 @@ test "Dir.Iterator but dir is deleted during iteration" { |
| 459 | 457 | defer tmp.cleanup(); |
| 460 | 458 | |
| 461 | 459 | // Create directory and setup an iterator for it |
| 462 | var iterable_subdir = try tmp.dir.makeOpenPathIterable("subdir", .{}); | |
| 463 | defer iterable_subdir.close(); | |
| 460 | var subdir = try tmp.dir.makeOpenPath("subdir", .{ .iterate = true }); | |
| 461 | defer subdir.close(); | |
| 464 | 462 | |
| 465 | var iterator = iterable_subdir.iterate(); | |
| 463 | var iterator = subdir.iterate(); | |
| 466 | 464 | |
| 467 | 465 | // Create something to iterate over within the subdir |
| 468 | 466 | try tmp.dir.makePath("subdir/b"); |
| ... | ... | @@ -964,7 +962,7 @@ test "makePath in a directory that no longer exists" { |
| 964 | 962 | fn testFilenameLimits(iterable_dir: Dir, maxed_filename: []const u8) !void { |
| 965 | 963 | // setup, create a dir and a nested file both with maxed filenames, and walk the dir |
| 966 | 964 | { |
| 967 | var maxed_dir = try iterable_dir.dir.makeOpenPath(maxed_filename, .{}); | |
| 965 | var maxed_dir = try iterable_dir.makeOpenPath(maxed_filename, .{}); | |
| 968 | 966 | defer maxed_dir.close(); |
| 969 | 967 | |
| 970 | 968 | try maxed_dir.writeFile(maxed_filename, ""); |
| ... | ... | @@ -981,7 +979,7 @@ fn testFilenameLimits(iterable_dir: Dir, maxed_filename: []const u8) !void { |
| 981 | 979 | } |
| 982 | 980 | |
| 983 | 981 | // ensure that we can delete the tree |
| 984 | try iterable_dir.dir.deleteTree(maxed_filename); | |
| 982 | try iterable_dir.deleteTree(maxed_filename); | |
| 985 | 983 | } |
| 986 | 984 | |
| 987 | 985 | test "max file name component lengths" { |
| ... | ... | @@ -992,16 +990,16 @@ test "max file name component lengths" { |
| 992 | 990 | // U+FFFF is the character with the largest code point that is encoded as a single |
| 993 | 991 | // UTF-16 code unit, so Windows allows for NAME_MAX of them. |
| 994 | 992 | const maxed_windows_filename = ("\u{FFFF}".*) ** std.os.windows.NAME_MAX; |
| 995 | try testFilenameLimits(tmp.iterable_dir, &maxed_windows_filename); | |
| 993 | try testFilenameLimits(tmp.dir, &maxed_windows_filename); | |
| 996 | 994 | } else if (builtin.os.tag == .wasi) { |
| 997 | 995 | // On WASI, the maxed filename depends on the host OS, so in order for this test to |
| 998 | 996 | // work on any host, we need to use a length that will work for all platforms |
| 999 | 997 | // (i.e. the minimum MAX_NAME_BYTES of all supported platforms). |
| 1000 | 998 | const maxed_wasi_filename = [_]u8{'1'} ** 255; |
| 1001 | try testFilenameLimits(tmp.iterable_dir, &maxed_wasi_filename); | |
| 999 | try testFilenameLimits(tmp.dir, &maxed_wasi_filename); | |
| 1002 | 1000 | } else { |
| 1003 | 1001 | const maxed_ascii_filename = [_]u8{'1'} ** std.fs.MAX_NAME_BYTES; |
| 1004 | try testFilenameLimits(tmp.iterable_dir, &maxed_ascii_filename); | |
| 1002 | try testFilenameLimits(tmp.dir, &maxed_ascii_filename); | |
| 1005 | 1003 | } |
| 1006 | 1004 | } |
| 1007 | 1005 | |
| ... | ... | @@ -1438,14 +1436,14 @@ test "walker without fully iterating" { |
| 1438 | 1436 | var tmp = tmpDir(.{ .iterate = true }); |
| 1439 | 1437 | defer tmp.cleanup(); |
| 1440 | 1438 | |
| 1441 | var walker = try tmp.iterable_dir.walk(testing.allocator); | |
| 1439 | var walker = try tmp.dir.walk(testing.allocator); | |
| 1442 | 1440 | defer walker.deinit(); |
| 1443 | 1441 | |
| 1444 | 1442 | // Create 2 directories inside the tmp directory, but then only iterate once before breaking. |
| 1445 | 1443 | // This ensures that walker doesn't try to close the initial directory when not fully iterating. |
| 1446 | 1444 | |
| 1447 | try tmp.iterable_dir.dir.makePath("a"); | |
| 1448 | try tmp.iterable_dir.dir.makePath("b"); | |
| 1445 | try tmp.dir.makePath("a"); | |
| 1446 | try tmp.dir.makePath("b"); | |
| 1449 | 1447 | |
| 1450 | 1448 | var num_walked: usize = 0; |
| 1451 | 1449 | while (try walker.next()) |_| { |
src/Package/Fetch.zig+14-12| ... | ... | @@ -280,7 +280,7 @@ pub fn run(f: *Fetch) RunError!void { |
| 280 | 280 | }, |
| 281 | 281 | .remote => |remote| remote, |
| 282 | 282 | .path_or_url => |path_or_url| { |
| 283 | if (fs.cwd().openIterableDir(path_or_url, .{})) |dir| { | |
| 283 | if (fs.cwd().openDir(path_or_url, .{ .iterate = true })) |dir| { | |
| 284 | 284 | var resource: Resource = .{ .dir = dir }; |
| 285 | 285 | return runResource(f, path_or_url, &resource, null); |
| 286 | 286 | } else |dir_err| { |
| ... | ... | @@ -363,7 +363,9 @@ fn runResource( |
| 363 | 363 | var tmp_directory: Cache.Directory = .{ |
| 364 | 364 | .path = tmp_directory_path, |
| 365 | 365 | .handle = handle: { |
| 366 | const dir = cache_root.handle.makeOpenPathIterable(tmp_dir_sub_path, .{}) catch |err| { | |
| 366 | const dir = cache_root.handle.makeOpenPath(tmp_dir_sub_path, .{ | |
| 367 | .iterate = true, | |
| 368 | }) catch |err| { | |
| 367 | 369 | try eb.addRootErrorMessage(.{ |
| 368 | 370 | .msg = try eb.printString("unable to create temporary directory '{s}': {s}", .{ |
| 369 | 371 | tmp_directory_path, @errorName(err), |
| ... | ... | @@ -371,7 +373,7 @@ fn runResource( |
| 371 | 373 | }); |
| 372 | 374 | return error.FetchFailed; |
| 373 | 375 | }; |
| 374 | break :handle dir.dir; | |
| 376 | break :handle dir; | |
| 375 | 377 | }, |
| 376 | 378 | }; |
| 377 | 379 | defer tmp_directory.handle.close(); |
| ... | ... | @@ -400,9 +402,9 @@ fn runResource( |
| 400 | 402 | if (builtin.os.tag == .linux and f.job_queue.work_around_btrfs_bug) { |
| 401 | 403 | // https://github.com/ziglang/zig/issues/17095 |
| 402 | 404 | tmp_directory.handle.close(); |
| 403 | const iterable_dir = cache_root.handle.makeOpenPathIterable(tmp_dir_sub_path, .{}) catch | |
| 404 | @panic("btrfs workaround failed"); | |
| 405 | tmp_directory.handle = iterable_dir.dir; | |
| 405 | tmp_directory.handle = cache_root.handle.makeOpenPath(tmp_dir_sub_path, .{ | |
| 406 | .iterate = true, | |
| 407 | }) catch @panic("btrfs workaround failed"); | |
| 406 | 408 | } |
| 407 | 409 | |
| 408 | 410 | f.actual_hash = try computeHash(f, tmp_directory, filter); |
| ... | ... | @@ -717,7 +719,7 @@ const Resource = union(enum) { |
| 717 | 719 | file: fs.File, |
| 718 | 720 | http_request: std.http.Client.Request, |
| 719 | 721 | git: Git, |
| 720 | dir: fs.IterableDir, | |
| 722 | dir: fs.Dir, | |
| 721 | 723 | |
| 722 | 724 | const Git = struct { |
| 723 | 725 | fetch_stream: git.Session.FetchStream, |
| ... | ... | @@ -1198,7 +1200,7 @@ fn unpackGitPack(f: *Fetch, out_dir: fs.Dir, resource: *Resource) anyerror!void |
| 1198 | 1200 | try out_dir.deleteTree(".git"); |
| 1199 | 1201 | } |
| 1200 | 1202 | |
| 1201 | fn recursiveDirectoryCopy(f: *Fetch, dir: fs.IterableDir, tmp_dir: fs.Dir) anyerror!void { | |
| 1203 | fn recursiveDirectoryCopy(f: *Fetch, dir: fs.Dir, tmp_dir: fs.Dir) anyerror!void { | |
| 1202 | 1204 | const gpa = f.arena.child_allocator; |
| 1203 | 1205 | // Recursive directory copy. |
| 1204 | 1206 | var it = try dir.walk(gpa); |
| ... | ... | @@ -1207,7 +1209,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.IterableDir, tmp_dir: fs.Dir) anyer |
| 1207 | 1209 | switch (entry.kind) { |
| 1208 | 1210 | .directory => {}, // omit empty directories |
| 1209 | 1211 | .file => { |
| 1210 | dir.dir.copyFile( | |
| 1212 | dir.copyFile( | |
| 1211 | 1213 | entry.path, |
| 1212 | 1214 | tmp_dir, |
| 1213 | 1215 | entry.path, |
| ... | ... | @@ -1215,14 +1217,14 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: fs.IterableDir, tmp_dir: fs.Dir) anyer |
| 1215 | 1217 | ) catch |err| switch (err) { |
| 1216 | 1218 | error.FileNotFound => { |
| 1217 | 1219 | if (fs.path.dirname(entry.path)) |dirname| try tmp_dir.makePath(dirname); |
| 1218 | try dir.dir.copyFile(entry.path, tmp_dir, entry.path, .{}); | |
| 1220 | try dir.copyFile(entry.path, tmp_dir, entry.path, .{}); | |
| 1219 | 1221 | }, |
| 1220 | 1222 | else => |e| return e, |
| 1221 | 1223 | }; |
| 1222 | 1224 | }, |
| 1223 | 1225 | .sym_link => { |
| 1224 | 1226 | var buf: [fs.MAX_PATH_BYTES]u8 = undefined; |
| 1225 | const link_name = try dir.dir.readLink(entry.path, &buf); | |
| 1227 | const link_name = try dir.readLink(entry.path, &buf); | |
| 1226 | 1228 | // TODO: if this would create a symlink to outside |
| 1227 | 1229 | // the destination directory, fail with an error instead. |
| 1228 | 1230 | tmp_dir.symLink(link_name, entry.path, .{}) catch |err| switch (err) { |
| ... | ... | @@ -1296,7 +1298,7 @@ fn computeHash( |
| 1296 | 1298 | var sus_dirs: std.StringArrayHashMapUnmanaged(void) = .{}; |
| 1297 | 1299 | defer sus_dirs.deinit(gpa); |
| 1298 | 1300 | |
| 1299 | var walker = try @as(fs.IterableDir, .{ .dir = tmp_directory.handle }).walk(gpa); | |
| 1301 | var walker = try tmp_directory.handle.walk(gpa); | |
| 1300 | 1302 | defer walker.deinit(); |
| 1301 | 1303 | |
| 1302 | 1304 | { |
src/Package/Fetch/git.zig+4-4| ... | ... | @@ -1384,11 +1384,11 @@ test "packfile indexing and checkout" { |
| 1384 | 1384 | var repository = try Repository.init(testing.allocator, pack_file, index_file); |
| 1385 | 1385 | defer repository.deinit(); |
| 1386 | 1386 | |
| 1387 | var worktree = testing.tmpIterableDir(.{}); | |
| 1387 | var worktree = testing.tmpDir(.{ .iterate = true }); | |
| 1388 | 1388 | defer worktree.cleanup(); |
| 1389 | 1389 | |
| 1390 | 1390 | const commit_id = try parseOid("dd582c0720819ab7130b103635bd7271b9fd4feb"); |
| 1391 | try repository.checkout(worktree.iterable_dir.dir, commit_id); | |
| 1391 | try repository.checkout(worktree.dir, commit_id); | |
| 1392 | 1392 | |
| 1393 | 1393 | const expected_files: []const []const u8 = &.{ |
| 1394 | 1394 | "dir/file", |
| ... | ... | @@ -1410,7 +1410,7 @@ test "packfile indexing and checkout" { |
| 1410 | 1410 | var actual_files: std.ArrayListUnmanaged([]u8) = .{}; |
| 1411 | 1411 | defer actual_files.deinit(testing.allocator); |
| 1412 | 1412 | defer for (actual_files.items) |file| testing.allocator.free(file); |
| 1413 | var walker = try worktree.iterable_dir.walk(testing.allocator); | |
| 1413 | var walker = try worktree.dir.walk(testing.allocator); | |
| 1414 | 1414 | defer walker.deinit(); |
| 1415 | 1415 | while (try walker.next()) |entry| { |
| 1416 | 1416 | if (entry.kind != .file) continue; |
| ... | ... | @@ -1442,7 +1442,7 @@ test "packfile indexing and checkout" { |
| 1442 | 1442 | \\revision 19 |
| 1443 | 1443 | \\ |
| 1444 | 1444 | ; |
| 1445 | const actual_file_contents = try worktree.iterable_dir.dir.readFileAlloc(testing.allocator, "file", max_file_size); | |
| 1445 | const actual_file_contents = try worktree.dir.readFileAlloc(testing.allocator, "file", max_file_size); | |
| 1446 | 1446 | defer testing.allocator.free(actual_file_contents); |
| 1447 | 1447 | try testing.expectEqualStrings(expected_file_contents, actual_file_contents); |
| 1448 | 1448 | } |
src/windows_sdk.zig+11-3| ... | ... | @@ -14,7 +14,11 @@ const product_version_max_length = version_major_minor_max_length + ".65535".len |
| 14 | 14 | /// Iterates via `iterator` and collects all folders with names starting with `optional_prefix` |
| 15 | 15 | /// and similar to SemVer. Returns slice of folder names sorted in descending order. |
| 16 | 16 | /// Caller owns result. |
| 17 | fn iterateAndFilterBySemVer(iterator: *std.fs.IterableDir.Iterator, allocator: std.mem.Allocator, comptime optional_prefix: ?[]const u8) error{ OutOfMemory, VersionNotFound }![][]const u8 { | |
| 17 | fn iterateAndFilterBySemVer( | |
| 18 | iterator: *std.fs.Dir.Iterator, | |
| 19 | allocator: std.mem.Allocator, | |
| 20 | comptime optional_prefix: ?[]const u8, | |
| 21 | ) error{ OutOfMemory, VersionNotFound }![][]const u8 { | |
| 18 | 22 | var dirs_filtered_list = std.ArrayList([]const u8).init(allocator); |
| 19 | 23 | errdefer { |
| 20 | 24 | for (dirs_filtered_list.items) |filtered_dir| allocator.free(filtered_dir); |
| ... | ... | @@ -476,7 +480,9 @@ pub const Windows81Sdk = struct { |
| 476 | 480 | if (!std.fs.path.isAbsolute(sdk_lib_dir_path)) return error.Windows81SdkNotFound; |
| 477 | 481 | |
| 478 | 482 | // enumerate files in sdk path looking for latest version |
| 479 | var sdk_lib_dir = std.fs.openIterableDirAbsolute(sdk_lib_dir_path, .{}) catch |err| switch (err) { | |
| 483 | var sdk_lib_dir = std.fs.openDirAbsolute(sdk_lib_dir_path, .{ | |
| 484 | .iterate = true, | |
| 485 | }) catch |err| switch (err) { | |
| 480 | 486 | error.NameTooLong => return error.PathTooLong, |
| 481 | 487 | else => return error.Windows81SdkNotFound, |
| 482 | 488 | }; |
| ... | ... | @@ -727,7 +733,9 @@ const MsvcLibDir = struct { |
| 727 | 733 | if (!std.fs.path.isAbsolute(visualstudio_folder_path)) return error.PathNotFound; |
| 728 | 734 | // enumerate folders that contain `privateregistry.bin`, looking for all versions |
| 729 | 735 | // f.i. %localappdata%\Microsoft\VisualStudio\17.0_9e9cbb98\ |
| 730 | var visualstudio_folder = std.fs.openIterableDirAbsolute(visualstudio_folder_path, .{}) catch return error.PathNotFound; | |
| 736 | var visualstudio_folder = std.fs.openDirAbsolute(visualstudio_folder_path, .{ | |
| 737 | .iterate = true, | |
| 738 | }) catch return error.PathNotFound; | |
| 731 | 739 | defer visualstudio_folder.close(); |
| 732 | 740 | |
| 733 | 741 | var iterator = visualstudio_folder.iterate(); |
test/src/Cases.zig+5-5| ... | ... | @@ -368,7 +368,7 @@ pub fn addCompile( |
| 368 | 368 | /// Each file should include a test manifest as a contiguous block of comments at |
| 369 | 369 | /// the end of the file. The first line should be the test type, followed by a set of |
| 370 | 370 | /// key-value config values, followed by a blank line, then the expected output. |
| 371 | pub fn addFromDir(ctx: *Cases, dir: std.fs.IterableDir) void { | |
| 371 | pub fn addFromDir(ctx: *Cases, dir: std.fs.Dir) void { | |
| 372 | 372 | var current_file: []const u8 = "none"; |
| 373 | 373 | ctx.addFromDirInner(dir, &current_file) catch |err| { |
| 374 | 374 | std.debug.panicExtra( |
| ... | ... | @@ -382,7 +382,7 @@ pub fn addFromDir(ctx: *Cases, dir: std.fs.IterableDir) void { |
| 382 | 382 | |
| 383 | 383 | fn addFromDirInner( |
| 384 | 384 | ctx: *Cases, |
| 385 | iterable_dir: std.fs.IterableDir, | |
| 385 | iterable_dir: std.fs.Dir, | |
| 386 | 386 | /// This is kept up to date with the currently being processed file so |
| 387 | 387 | /// that if any errors occur the caller knows it happened during this file. |
| 388 | 388 | current_file: *[]const u8, |
| ... | ... | @@ -416,7 +416,7 @@ fn addFromDirInner( |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | const max_file_size = 10 * 1024 * 1024; |
| 419 | const src = try iterable_dir.dir.readFileAllocOptions(ctx.arena, filename, max_file_size, null, 1, 0); | |
| 419 | const src = try iterable_dir.readFileAllocOptions(ctx.arena, filename, max_file_size, null, 1, 0); | |
| 420 | 420 | |
| 421 | 421 | // Parse the manifest |
| 422 | 422 | var manifest = try TestManifest.parse(ctx.arena, src); |
| ... | ... | @@ -1246,7 +1246,7 @@ pub fn main() !void { |
| 1246 | 1246 | var filenames = std.ArrayList([]const u8).init(arena); |
| 1247 | 1247 | |
| 1248 | 1248 | const case_dirname = std.fs.path.dirname(case_file_path).?; |
| 1249 | var iterable_dir = try std.fs.cwd().openIterableDir(case_dirname, .{}); | |
| 1249 | var iterable_dir = try std.fs.cwd().openDir(case_dirname, .{ .iterate = true }); | |
| 1250 | 1250 | defer iterable_dir.close(); |
| 1251 | 1251 | |
| 1252 | 1252 | if (std.mem.endsWith(u8, case_file_path, ".0.zig")) { |
| ... | ... | @@ -1280,7 +1280,7 @@ pub fn main() !void { |
| 1280 | 1280 | |
| 1281 | 1281 | for (batch) |filename| { |
| 1282 | 1282 | const max_file_size = 10 * 1024 * 1024; |
| 1283 | const src = try iterable_dir.dir.readFileAllocOptions(arena, filename, max_file_size, null, 1, 0); | |
| 1283 | const src = try iterable_dir.readFileAllocOptions(arena, filename, max_file_size, null, 1, 0); | |
| 1284 | 1284 | |
| 1285 | 1285 | // Parse the manifest |
| 1286 | 1286 | var manifest = try TestManifest.parse(arena, src); |
test/tests.zig+1-1| ... | ... | @@ -1288,7 +1288,7 @@ pub fn addCases( |
| 1288 | 1288 | |
| 1289 | 1289 | var cases = @import("src/Cases.zig").init(gpa, arena); |
| 1290 | 1290 | |
| 1291 | var dir = try b.build_root.handle.openIterableDir("test/cases", .{}); | |
| 1291 | var dir = try b.build_root.handle.openDir("test/cases", .{ .iterate = true }); | |
| 1292 | 1292 | defer dir.close(); |
| 1293 | 1293 | |
| 1294 | 1294 | cases.addFromDir(dir); |
tools/generate_JSONTestSuite.zig+1-1| ... | ... | @@ -18,7 +18,7 @@ pub fn main() !void { |
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | 20 | var names = std.ArrayList([]const u8).init(allocator); |
| 21 | var cwd = try std.fs.cwd().openIterableDir(".", .{}); | |
| 21 | var cwd = try std.fs.cwd().openDir(".", .{ .iterate = true }); | |
| 22 | 22 | var it = cwd.iterate(); |
| 23 | 23 | while (try it.next()) |entry| { |
| 24 | 24 | try names.append(try allocator.dupe(u8, entry.name)); |