05975959e67f57063445baabb652262dd764cc72 added a use of `O_NONBLOCK` but
the constant cannot be imported from wasi-libc through ClangImporter
directly, so we need to add a shim for it as well as other constants.
* Gate `fchown` and `fchmod` calls behind `os(WASI)`
They are not available on WASI, so we gate them behind `os(WASI)`.
* Add missing constant shims for wasi-libc
* Use `futimens` instead of legacy `futimes`
wasi-libc does not provide `futimes` as it is a legacy function.
574b88da48/libc-top-half/musl/include/sys/time.h (L34)
* Port directory enumeration related code to WASI
For now wasi-libc does not include fts(3) implementation, so mark
features depending on it as unsupported on WASI. Once wasi-libc includes
fts or we decide to implement and maintain our own fts-like API, we can
remove these `#if os(WASI)` guards.
wasi-libc issue tracking fts support:
https://github.com/WebAssembly/wasi-libc/issues/520
Also, wasi-libc defines some constants in a way that ClangImporter can't
understand, so we need to grab them manually through _FoundationCShims in
function call form.
* Delegate error throwing decisions to the delegate