Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc4e5af

Browse files
committed
Fix get_dirent_type() for symlinks on MinGW/MSYS.
On Windows with MSVC, get_dirent_type() was recently made to returnDT_LNK for junction points by commit9d3444d, which fixed somedefective dirent.c code.On Windows with Cygwin, get_dirent_type() already worked for symlinks,as it does on POSIX systems, because Cygwin has its own fake symlinksthat behave like POSIX (on closer inspection, Cygwin's dirent has theBSD d_type extension but it's probably always DT_UNKNOWN, so we fallback to lstat(), which understands Cygwin symlinks with S_ISLNK()).On Windows with MinGW/MSYS, we need extra code, because the MinGWruntime has its own readdir() without d_type, and the lstat()-basedfallback has no knowledge of our convention for treating junctions assymlinks.Back-patch to 14, where get_dirent_type() landed.Reported-by: Andrew Dunstan <andrew@dunslane.net>Discussion:https://postgr.es/m/b9ddf605-6b36-f90d-7c30-7b3e95c46276%40dunslane.net
1 parent1d01d19 commitfc4e5af

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎src/common/file_utils.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,21 @@ get_dirent_type(const char *path,
465465
#endif
466466
}
467467

468+
#if defined(WIN32)&& !defined(_MSC_VER)
469+
470+
/*
471+
* If we're on native Windows (not Cygwin, which has its own POSIX
472+
* symlinks), but not using the MSVC compiler, then we're using a
473+
* readdir() emulation provided by the MinGW runtime that has no d_type.
474+
* Since the lstat() fallback code reports junction points as directories,
475+
* we need an extra system call to check if we should report them as
476+
* symlinks instead, following our convention.
477+
*/
478+
if (result==PGFILETYPE_DIR&&
479+
!look_through_symlinks&&
480+
pgwin32_is_junction(path))
481+
result=PGFILETYPE_LNK;
482+
#endif
483+
468484
returnresult;
469485
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp