authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-09-26 02:22:53 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-09-26 02:22:53 -07:00
logcc70136035c48b56811d008bf6504ba3ee5d075c
tree574cf18b1c366627daf562bee18c93f8759840c5
parent6b617fc40eb889d5138ab3c00a1f79db7f15385b

add doesFolderExist


1 files changed, 14 insertions(+), 0 deletions(-)

src/lib.zig+14
...@@ -63,3 +63,17 @@ pub fn asciiUpper(alloc: *std.mem.Allocator, input: string) ![]u8 {...@@ -63,3 +63,17 @@ pub fn asciiUpper(alloc: *std.mem.Allocator, input: string) ![]u8 {
63 }63 }
64 return buf;64 return buf;
65}65}
66
67pub 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}