This is available on most platforms (Linux/Mac/Win/BSD) with no extra syscalls.
On other platforms (e.g. Solaris) we stat() if this information is requested.
This will allow switching clang's VFS to efficiently expose (path, type) when
traversing a directory. Currently it exposes an entire Status, but does so by
calling fs::status() on all platforms.
Almost all callers only need the path, and all callers only need (path, type).
Picking this up a year later by noticing that _DIRENT_HAVE_D_TYPE isn't actually defined in macOS's headers, which means it probably isn't in BSD either. Do you think just testing for DTTOIF would be sufficient?