summaryrefslogtreecommitdiff
path: root/src/os_mswin.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-01-10 13:05:20 +0100
committerBram Moolenaar <Bram@vim.org>2014-01-10 13:05:20 +0100
commitb1cb35f785d2d7a1c94268218cf5eb3d8087c55e (patch)
tree5e1a197aa11fdef4a777fa2de6d53743793ae928 /src/os_mswin.c
parent438f67a0040ab4f517c68f446f4a03a6c9e9096d (diff)
downloadvim-git-b1cb35f785d2d7a1c94268218cf5eb3d8087c55e.tar.gz
updated for version 7.4.136v7.4.136
Problem: MS-Windows: When saving a file with a UNC path the file becomes read-only. Solution: Don't mix up Win32 attributes and Unix attributes. (Ken Takata)
Diffstat (limited to 'src/os_mswin.c')
-rw-r--r--src/os_mswin.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c
index 95c3d1738..4b2f3cf07 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -617,8 +617,22 @@ vim_stat(const char *name, struct stat *stp)
p = buf + strlen(buf);
if (p > buf)
mb_ptr_back(buf, p);
+
+ /* Remove trailing '\\' except root path. */
if (p > buf && (*p == '\\' || *p == '/') && p[-1] != ':')
*p = NUL;
+
+ if ((buf[0] == '\\' && buf[1] == '\\') || (buf[0] == '/' && buf[1] == '/'))
+ {
+ /* UNC root path must be followed by '\\'. */
+ p = vim_strpbrk(buf + 2, "\\/");
+ if (p != NULL)
+ {
+ p = vim_strpbrk(p + 1, "\\/");
+ if (p == NULL)
+ STRCAT(buf, "\\");
+ }
+ }
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage
# ifdef __BORLANDC__