| ... | ... | @@ -63,3 +63,17 @@ pub fn asciiUpper(alloc: *std.mem.Allocator, input: string) ![]u8 { |
| 63 | 63 | } |
| 64 | 64 | return buf; |
| 65 | 65 | } |
| 66 | |
| 67 | pub fn doesFolderExist(dir: ?std.fs.Dir, fpath: []const u8) !bool { |
| 68 | const file = (dir orelse std.fs.cwd()).openFile(fpath, .{}) catch |e| switch (e) { |
| 69 | error.FileNotFound => return false, |
| 70 | error.IsDir => return true, |
| 71 | else => return e, |
| 72 | }; |
| 73 | defer file.close(); |
| 74 | const s = try file.stat(); |
| 75 | if (s.kind != .Directory) { |
| 76 | return false; |
| 77 | } |
| 78 | return true; |
| 79 | } |