summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-01-19 19:00:32 +0100
committerBram Moolenaar <Bram@vim.org>2016-01-19 19:00:32 +0100
commitfce7b3d24fd18b1486e474e933a95f9090df9973 (patch)
tree53877cdc2315dc41804a1afc55a547b3840624f6
parent3a466a87180d677b898687ef72d09f14a397794e (diff)
patch 7.4.1139v7.4.1139
Problem: MS-Windows: getftype() returns "file for symlink to directory. Solution: Make it return "dir". (Ken Takata)
-rw-r--r--src/os_mswin.c24
-rw-r--r--src/version.c2
2 files changed, 20 insertions, 6 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c
index daf71a304d..698c210f44 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -506,12 +506,16 @@ slash_adjust(p)
static int
stat_symlink_aware(const char *name, struct stat *stp)
{
-#if defined(_MSC_VER) && _MSC_VER < 1700
- /* Work around for VC10 or earlier. stat() can't handle symlinks properly.
+#if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__)
+ /* Work around for VC12 or earlier (and MinGW). stat() can't handle
+ * symlinks properly.
* VC9 or earlier: stat() doesn't support a symlink at all. It retrieves
* status of a symlink itself.
* VC10: stat() supports a symlink to a normal file, but it doesn't support
- * a symlink to a directory (always returns an error). */
+ * a symlink to a directory (always returns an error).
+ * VC11 and VC12: stat() doesn't return an error for a symlink to a
+ * directory, but it doesn't set S_IFDIR flag.
+ * MinGW: Same as VC9. */
WIN32_FIND_DATA findData;
HANDLE hFind, h;
DWORD attr = 0;
@@ -540,6 +544,8 @@ stat_symlink_aware(const char *name, struct stat *stp)
fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY);
n = _fstat(fd, (struct _stat*)stp);
+ if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY))
+ stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR;
_close(fd);
return n;
}
@@ -552,12 +558,16 @@ stat_symlink_aware(const char *name, struct stat *stp)
static int
wstat_symlink_aware(const WCHAR *name, struct _stat *stp)
{
-# if defined(_MSC_VER) && _MSC_VER < 1700
- /* Work around for VC10 or earlier. _wstat() can't handle symlinks properly.
+# if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__)
+ /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle
+ * symlinks properly.
* VC9 or earlier: _wstat() doesn't support a symlink at all. It retrieves
* status of a symlink itself.
* VC10: _wstat() supports a symlink to a normal file, but it doesn't
- * support a symlink to a directory (always returns an error). */
+ * support a symlink to a directory (always returns an error).
+ * VC11 and VC12: _wstat() doesn't return an error for a symlink to a
+ * directory, but it doesn't set S_IFDIR flag.
+ * MinGW: Same as VC9. */
int n;
BOOL is_symlink = FALSE;
HANDLE hFind, h;
@@ -587,6 +597,8 @@ wstat_symlink_aware(const WCHAR *name, struct _stat *stp)
fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY);
n = _fstat(fd, stp);
+ if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY))
+ stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR;
_close(fd);
return n;
}
diff --git a/src/version.c b/src/version.c
index d42a237776..5a0ed90d34 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1139,
+/**/
1138,
/**/
1137,