Thomas Munro <thomas(dot)munro(at)gmail(dot)com> writes:
> You don't need to call stat() just to find out if a dirent is a file
> or directory, most of the time. Please see attached.
Hm. If we do this, I can see wanting to apply the knowledge in more
places than walkdir(). Is it possible to extract out the nonstandard
bits into a reusable subroutine? I'm envisioning an API more or less
like
extern enum PGFileType identify_file_type(const char *path,
const struct dirent *de,
bool look_thru_symlinks);
regards, tom lane