Hi,
After the patch 7.4.096, when edit and save a file on a UNC path, the file
becomes unexpectedly readonly. mch_getperm() should return permissions in
a unix style like 0644 or 0777, but it returns Win32 attributes for a UNC
path after 7.4.096. vim_stat() should have been changed to accept a UNC path.
Attached patch fixes this.
Regards,
Ken Takata
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
# HG changeset patch
# Parent 55cd783bbc2d69a4baea9125ba53fa787aed3780
diff --git a/src/os_mswin.c b/src/os_mswin.c
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -617,8 +617,20 @@
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)
+ {
+ p = vim_strpbrk(p + 1, "\\/");
+ if (p == NULL)
+ STRCAT(buf, "\\");
+ }
+ }
#ifdef FEAT_MBYTE
if (enc_codepage >= 0 && (int)GetACP() != enc_codepage
# ifdef __BORLANDC__
diff --git a/src/os_win32.c b/src/os_win32.c
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2890,9 +2890,6 @@
struct stat st;
int n;
- if (name[0] == '\\' && name[1] == '\\')
- /* UNC path */
- return (long)win32_getattrs(name);
n = mch_stat(name, &st);
return n == 0 ? (long)st.st_mode : -1L;
}