mirror of
https://github.com/postgres/postgres.git
synced 2025-09-02 04:21:28 +03:00
Add d_type to our Windows dirent emulation.
This allows us to skip some stat calls, by extending commit 861c6e7c
to
cover Windows systems.
Author: Juan José Santamaría Flecha <juanjo.santamaria@gmail.com>
Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Magnus Hagander <magnus@hagander.net>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKG%2BFzxupGGN4GpUdbzZN%2Btn6FQPHo8w0Q%2BAPH5Wz8RG%2Bww%40mail.gmail.com
This commit is contained in:
@@ -69,6 +69,7 @@ opendir(const char *dirname)
|
||||
d->handle = INVALID_HANDLE_VALUE;
|
||||
d->ret.d_ino = 0; /* no inodes on win32 */
|
||||
d->ret.d_reclen = 0; /* not used on win32 */
|
||||
d->ret.d_type = DT_UNKNOWN;
|
||||
|
||||
return d;
|
||||
}
|
||||
@@ -105,6 +106,15 @@ readdir(DIR *d)
|
||||
}
|
||||
strcpy(d->ret.d_name, fd.cFileName); /* Both strings are MAX_PATH long */
|
||||
d->ret.d_namlen = strlen(d->ret.d_name);
|
||||
/* The only identified types are: directory, regular file or symbolic link */
|
||||
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
|
||||
d->ret.d_type = DT_DIR;
|
||||
/* For reparse points dwReserved0 field will contain the ReparseTag */
|
||||
else if ((fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 &&
|
||||
(fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
|
||||
d->ret.d_type = DT_LNK;
|
||||
else
|
||||
d->ret.d_type = DT_REG;
|
||||
|
||||
return &d->ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user