fix: is_directory should return false for non-existent (new) files

This commit is contained in:
CJ van den Berg 2024-07-02 09:54:35 +02:00
parent 1a42894f6d
commit 563772659f

View file

@ -555,7 +555,10 @@ fn restart() noreturn {
pub fn is_directory(rel_path: []const u8) !bool {
var path_buf: [std.fs.max_path_bytes]u8 = undefined;
const abs_path = try std.fs.cwd().realpath(rel_path, &path_buf);
const abs_path = std.fs.cwd().realpath(rel_path, &path_buf) catch |e| switch(e) {
error.FileNotFound => return false,
else => return e,
};
var dir = std.fs.openDirAbsolute(abs_path, .{}) catch |e| switch (e) {
error.NotDir => return false,
else => return e,