This is direct result of review comments left by andrewrk and
daurnimator. It makes sense to map `ENOTCAPABLE` into a more generic
`error.AccessDenied`.
This commit adds `error.NotCapable` enum value and makes sure that
every applicable WASI syscall that can return `ENOTCAPABLE` errno
remaps it to `error.NotCapable.
Also, add more informative `@compileError` in a few `std.os` functions
that would otherwise yield a cryptic compile error when targeting
WASI. Finally, enhance docs in a few places and add test case for
`fstatat`.
This commit generalizes `std.fs.wasi.PreopenList.find(...)` allowing
search by `std.fs.wasi.PreopenType` union type rather than by dir
name. In the future releases of WASI, it is expected to have more
preopen types (or capabilities) than just directories. This commit
aligns itself with that vision.
This is a potentially breaking change. However, since `std.fs.wasi.PreopenList`
wasn't made part of any Zig release yet, I think we should be OK
to introduce those changes without pointing to any deprecations.
This commit adds some unit tests for `std.fs.File.readAllAlloc`
function. It also updates the docs of `Reader.readNoEof`
which were outdated, and swaps `inStream()` for `reader()` in
`File.readAllAlloc` with the former being deprecated.
Adds Windows stub (still needs to be implemented on Windows),
adds WASI implementation, adds unit test testing basic chain of
ops: create file -> symlink -> readlink.
* `std.fs.Dir.Entry.Kind` is moved to `std.fs.File.Kind`
* `std.fs.File.Stat` gains the `kind` field, so performing a stat() on
a File now tells what kind of file it is. On Windows this only will
distinguish between directories and files.
* rework zig fmt logic so that in the case of opening a file and
discovering it to be a directory, it closes the file descriptor
before re-opening it with O_DIRECTORY, using fewer simultaneous open
file descriptors when walking a directory tree.
* rework zig fmt logic so that it pays attention to the kind of
directory entries, and when it sees a sub-directory it attempts to
open it as a directory rather than a file, reducing the number of
open() syscalls when walking a directory tree.