From 34a35bbf09436dc3036f66acf49d7180dd8b1215 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 6 May 2021 03:06:45 -0700 Subject: [PATCH] util: remove u.mkdir_all, closes #11 --- src/common.zig | 2 +- src/util/dep_type.zig | 2 +- src/util/funcs.zig | 14 -------------- 3 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/common.zig b/src/common.zig index 9414f3a42fe7f2de9d07a6b1fa6d2e30ab8e2dad..ac836f65b86b32113bb8c47b616f1f9728bc55a1 100644 --- a/src/common.zig +++ b/src/common.zig @@ -102,7 +102,7 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, comptime o u.assert(false, "fetch: git: {s}: {s} {s} does not exist", .{ d.path, @tagName(vers.id), vers.string }); } const td_fd = try fs.cwd().openDir(basedir, .{}); - try u.mkdir_all(pv); + try fs.cwd().makePath(pv); try td_fd.rename("temp", try d.clean_path_v()); if (vers.id != .branch) { const pvd = try std.fs.cwd().openDir(pv, .{}); diff --git a/src/util/dep_type.zig b/src/util/dep_type.zig index 3571335f81c57651d10efe82e368943a0555478f..0d5721def79b5df9b11bba11a7261f9bcf206d94 100644 --- a/src/util/dep_type.zig +++ b/src/util/dep_type.zig @@ -40,7 +40,7 @@ pub const DepType = enum { _ = try u.run_cmd(null, &.{ "hg", "clone", rpath, dpath }); }, .http => { - try u.mkdir_all(dpath); + try std.fs.cwd().makePath(dpath); _ = try u.run_cmd(dpath, &.{ "wget", rpath }); const f = rpath[std.mem.lastIndexOf(u8, rpath, "/").? + 1 ..]; if (std.mem.endsWith(u8, f, ".zip")) { diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 3f52642bbaa5119413ca06854dce73fdf8de070c..42dcc03ce2ca6eea0caa8bb98b959bbe6691b509 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -186,20 +186,6 @@ pub fn last(in: [][]const u8) ![]const u8 { return in[in.len - 1]; } -pub fn mkdir_all(dpath: []const u8) anyerror!void { - if (dpath.len == 0) { - return; - } - const d = if (dpath[dpath.len - 1] == std.fs.path.sep) dpath[0 .. dpath.len - 1] else dpath; - const ps = std.fs.path.sep_str; - if (std.mem.lastIndexOf(u8, d, ps)) |index| { - try mkdir_all(d[0..index]); - } - if (!try does_folder_exist(d)) { - try std.fs.cwd().makeDir(d); - } -} - pub fn rm_recv(path: []const u8) anyerror!void { const abs_path = std.fs.realpathAlloc(gpa, path) catch |e| switch (e) { error.FileNotFound => return, -- 2.54.0