While doing codecrafters Build your own shell stage 5 i need to check if file is executable. How do i do it in Zig 0.16.0?
Of course finally after posting this question i found Dir.access
1 Like
You probably want File.stat instead and check for executable permission.
1 Like
Assuming linux? Definition of what’s executable varies by platform.
Unix yeah. On windows idk. The stat gives more info like the kind of the file, but with std.Io.File it should already point to not at least a directory, for which in unix if executable bit is set on a directory it means you can access the subpaths inside. But more importantly, using access instead of fstatat is prone to TOCTOU.