1/*-------------------------------------------------------------------------
4 * opendir/readdir/closedir for win32/msvc
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
13 *-------------------------------------------------------------------------
38 /* Make sure it is a directory */
39 attr = GetFileAttributes(dirname);
40 if (attr == INVALID_FILE_ATTRIBUTES)
45 if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
67 strcat(d->
dirname,
"\\");
/* Append backslash if not already there */
68 strcat(d->
dirname,
"*");
/* Search for entries named anything */
69 d->
handle = INVALID_HANDLE_VALUE;
70 d->
ret.
d_ino = 0;
/* no inodes on win32 */
82 if (d->
handle == INVALID_HANDLE_VALUE)
85 if (d->
handle == INVALID_HANDLE_VALUE)
87 /* If there are no files, force errno=0 (unlike mingw) */
88 if (GetLastError() == ERROR_FILE_NOT_FOUND)
99 /* If there are no more files, force errno=0 (like mingw) */
100 if (GetLastError() == ERROR_NO_MORE_FILES)
107 strcpy(d->
ret.
d_name,
fd.cFileName);
/* Both strings are MAX_PATH long */
111 * For reparse points dwReserved0 field will contain the ReparseTag. We
112 * check this first, because reparse points are also reported as
115 if ((
fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) != 0 &&
116 (
fd.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT))
118 else if ((
fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
131 if (d->
handle != INVALID_HANDLE_VALUE)
132 ret = !FindClose(d->
handle);
struct dirent * readdir(DIR *d)
DIR * opendir(const char *dirname)
static int fd(const char *x, int i)
void _dosmaperr(unsigned long)