authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-06 03:10:11 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-05-06 03:10:11 -07:00
logcdbcca208bb393e6e92247272c402f7df46fb737
tree862e53e9dcd86f072e14df16930fdb20ad8a0016
parent34a35bbf09436dc3036f66acf49d7180dd8b1215

util: remove u.rm_recv


2 files changed, 2 insertions(+), 24 deletions(-)

src/common.zig+2-2
......@@ -144,12 +144,12 @@ fn get_moddir(basedir: []const u8, d: u.Dep, parent_name: []const u8, comptime o
144144 try std.fs.cwd().deleteFile(file_path);
145145 return pv;
146146 }
147 try u.rm_recv(pv);
147 try std.fs.cwd().deleteTree(pv);
148148 u.assert(false, "{s} does not match hash {s}", .{ d.path, d.version });
149149 return p;
150150 }
151151 if (try u.does_folder_exist(p)) {
152 try u.rm_recv(p);
152 try std.fs.cwd().deleteTree(p);
153153 }
154154 const file_path = try std.fs.path.join(gpa, &.{ p, file_name });
155155 try d.type.pull(d.path, p);
src/util/funcs.zig-22
......@@ -186,28 +186,6 @@ pub fn last(in: [][]const u8) ![]const u8 {
186186 return in[in.len - 1];
187187}
188188
189pub fn rm_recv(path: []const u8) anyerror!void {
190 const abs_path = std.fs.realpathAlloc(gpa, path) catch |e| switch (e) {
191 error.FileNotFound => return,
192 else => return e,
193 };
194 const file = try std.fs.openFileAbsolute(abs_path, .{});
195 defer file.close();
196 const s = try file.stat();
197 if (s.kind == .Directory) {
198 const dir = std.fs.cwd().openDir(abs_path, .{
199 .iterate = true,
200 }) catch unreachable;
201 var iter = dir.iterate();
202 while (try iter.next()) |item| {
203 try rm_recv(try std.fs.path.join(gpa, &.{ abs_path, item.name }));
204 }
205 try std.fs.deleteDirAbsolute(abs_path);
206 } else {
207 try std.fs.deleteFileAbsolute(abs_path);
208 }
209}
210
211189const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
212190
213191pub fn random_string(len: usize) ![]const u8 {