| ... | @@ -77,3 +77,13 @@ pub fn doesFolderExist(dir: ?std.fs.Dir, fpath: []const u8) !bool { | ... | @@ -77,3 +77,13 @@ pub fn doesFolderExist(dir: ?std.fs.Dir, fpath: []const u8) !bool { |
| 77 | } | 77 | } |
| 78 | return true; | 78 | return true; |
| 79 | } | 79 | } |
| | 80 | |
| | 81 | pub fn doesFileExist(dir: ?std.fs.Dir, fpath: []const u8) !bool { |
| | 82 | const file = (dir orelse std.fs.cwd()).openFile(fpath, .{}) catch |e| switch (e) { |
| | 83 | error.FileNotFound => return false, |
| | 84 | error.IsDir => return true, |
| | 85 | else => return e, |
| | 86 | }; |
| | 87 | defer file.close(); |
| | 88 | return true; |
| | 89 | } |