authorgravatar for gereeter+code@gmail.comJonathan S <gereeter+code@gmail.com> 2019-11-22 16:32:50-06:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-25 23:46:48-05:00
log4014a8e4b44bad5aca896ce0fdf120ef4212fc8d
tree905180f165743072aa1409199ae06897474120ff
parent001334266a0f6d0d7da4e0eba5b5e317456a39ff

Avoid deprecated cwd-based functions for opening directories, preferring to open explicitly relative to `Dir.cwd()`.


5 files changed, 9 insertions(+), 9 deletions(-)

lib/std/fs.zig+5-5
......@@ -350,7 +350,7 @@ pub fn deleteTree(full_path: []const u8) !void {
350350 CannotDeleteRootDirectory,
351351 }.CannotDeleteRootDirectory;
352352
353 var dir = try Dir.open(dirname);
353 var dir = try Dir.cwd().openDirList(dirname);
354354 defer dir.close();
355355
356356 return dir.deleteTree(path.basename(full_path));
......@@ -1066,7 +1066,7 @@ pub const Dir = struct {
10661066 error.Unexpected,
10671067 => |e| return e,
10681068 }
1069 var dir = self.openDir(sub_path) catch |err| switch (err) {
1069 var dir = self.openDirList(sub_path) catch |err| switch (err) {
10701070 error.NotDir => {
10711071 if (got_access_denied) {
10721072 return error.AccessDenied;
......@@ -1131,7 +1131,7 @@ pub const Dir = struct {
11311131 => |e| return e,
11321132 }
11331133
1134 const new_dir = dir.openDir(entry.name) catch |err| switch (err) {
1134 const new_dir = dir.openDirList(entry.name) catch |err| switch (err) {
11351135 error.NotDir => {
11361136 if (got_access_denied) {
11371137 return error.AccessDenied;
......@@ -1222,7 +1222,7 @@ pub const Walker = struct {
12221222 try self.name_buffer.appendByte(path.sep);
12231223 try self.name_buffer.append(base.name);
12241224 if (base.kind == .Directory) {
1225 var new_dir = top.dir_it.dir.openDir(base.name) catch |err| switch (err) {
1225 var new_dir = top.dir_it.dir.openDirList(base.name) catch |err| switch (err) {
12261226 error.NameTooLong => unreachable, // no path sep in base.name
12271227 else => |e| return e,
12281228 };
......@@ -1260,7 +1260,7 @@ pub const Walker = struct {
12601260pub fn walkPath(allocator: *Allocator, dir_path: []const u8) !Walker {
12611261 assert(!mem.endsWith(u8, dir_path, path.sep_str));
12621262
1263 var dir = try Dir.open(dir_path);
1263 var dir = try Dir.cwd().openDirList(dir_path);
12641264 errdefer dir.close();
12651265
12661266 var name_buffer = try std.Buffer.init(allocator, dir_path);
lib/std/os/test.zig+1-1
......@@ -20,7 +20,7 @@ test "makePath, put some files in it, deleteTree" {
2020 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "c" ++ fs.path.sep_str ++ "file.txt", "nonsense");
2121 try io.writeFile("os_test_tmp" ++ fs.path.sep_str ++ "b" ++ fs.path.sep_str ++ "file2.txt", "blah");
2222 try fs.deleteTree("os_test_tmp");
23 if (fs.Dir.open("os_test_tmp")) |dir| {
23 if (fs.Dir.cwd().openDirTraverse("os_test_tmp")) |dir| {
2424 @panic("expected error");
2525 } else |err| {
2626 expect(err == error.FileNotFound);
src-self-hosted/main.zig+1-1
......@@ -715,7 +715,7 @@ async fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtErro
715715 // ) catch |err| switch (err) {
716716 // error.IsDir, error.AccessDenied => {
717717 // // TODO make event based (and dir.next())
718 // var dir = try fs.Dir.open(file_path);
718 // var dir = try fs.Dir.cwd().openDirList(file_path);
719719 // defer dir.close();
720720
721721 // var group = event.Group(FmtError!void).init(fmt.allocator);
src-self-hosted/stage1.zig+1-1
......@@ -279,7 +279,7 @@ fn fmtPath(fmt: *Fmt, file_path_ref: []const u8, check_mode: bool) FmtError!void
279279 const source_code = io.readFileAlloc(fmt.allocator, file_path) catch |err| switch (err) {
280280 error.IsDir, error.AccessDenied => {
281281 // TODO make event based (and dir.next())
282 var dir = try fs.Dir.open(file_path);
282 var dir = try fs.Dir.cwd().openDirList(file_path);
283283 defer dir.close();
284284
285285 var dir_it = dir.iterate();
tools/process_headers.zig+1-1
......@@ -340,7 +340,7 @@ pub fn main() !void {
340340 try dir_stack.append(target_include_dir);
341341
342342 while (dir_stack.popOrNull()) |full_dir_name| {
343 var dir = std.fs.Dir.open(full_dir_name) catch |err| switch (err) {
343 var dir = std.fs.Dir.cwd().openDirList(full_dir_name) catch |err| switch (err) {
344344 error.FileNotFound => continue :search,
345345 error.AccessDenied => continue :search,
346346 else => return err,