Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/std/fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1135,6 +1135,11 @@ pub const Dir = struct {
w.RIGHT.FD_FILESTAT_SET_SIZE;
}
const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);
errdefer os.close(fd);
const fstat = try os.fstat(fd);
const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;
if (is_dir) return error.IsDir;

return File{ .handle = fd };
}

Expand Down Expand Up @@ -1192,6 +1197,11 @@ pub const Dir = struct {
});
}
}
if (builtin.target.os.tag == .wasi) {
const fstat = try os.fstat(fd);
const is_dir = fstat.mode & os.S.IFMT == os.S.IFDIR;
if (is_dir) return error.IsDir;
}

if (has_flock_open_flags and flags.lock_nonblocking) {
var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
Expand Down