diff --git a/src/util/funcs.zig b/src/util/funcs.zig index aac2980e6ba6e5953e3f24b4101853f1edb8bff4..c7910f3ca4f9fd33079f5254a16711ef0369cd2f 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -186,13 +186,14 @@ pub fn last(in: [][]const u8) ![]const u8 { } 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; - const e = dpath[0..std.mem.lastIndexOf(u8, dpath, ps).?]; - if (std.mem.indexOf(u8, e, ps)) |_| {} else { - return; + if (std.mem.lastIndexOf(u8, d, ps)) |index| { + try mkdir_all(d[0..index]); } - try mkdir_all(e); if (!try does_folder_exist(d)) { try std.fs.cwd().makeDir(d); }