| ... | @@ -186,13 +186,14 @@ pub fn last(in: [][]const u8) ![]const u8 { | ... | @@ -186,13 +186,14 @@ pub fn last(in: [][]const u8) ![]const u8 { |
| 186 | } | 186 | } |
| 187 | | 187 | |
| 188 | pub fn mkdir_all(dpath: []const u8) anyerror!void { | 188 | pub fn mkdir_all(dpath: []const u8) anyerror!void { |
| | 189 | if (dpath.len == 0) { |
| | 190 | return; |
| | 191 | } |
| 189 | const d = if (dpath[dpath.len-1] == std.fs.path.sep) dpath[0..dpath.len-1] else dpath; | 192 | const d = if (dpath[dpath.len-1] == std.fs.path.sep) dpath[0..dpath.len-1] else dpath; |
| 190 | const ps = std.fs.path.sep_str; | 193 | const ps = std.fs.path.sep_str; |
| 191 | const e = dpath[0..std.mem.lastIndexOf(u8, dpath, ps).?]; | 194 | if (std.mem.lastIndexOf(u8, d, ps)) |index| { |
| 192 | if (std.mem.indexOf(u8, e, ps)) |_| {} else { | 195 | try mkdir_all(d[0..index]); |
| 193 | return; | | |
| 194 | } | 196 | } |
| 195 | try mkdir_all(e); | | |
| 196 | if (!try does_folder_exist(d)) { | 197 | if (!try does_folder_exist(d)) { |
| 197 | try std.fs.cwd().makeDir(d); | 198 | try std.fs.cwd().makeDir(d); |
| 198 | } | 199 | } |