summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-08-18 20:20:27 +0200
committerBram Moolenaar <Bram@vim.org>2018-08-18 20:20:27 +0200
commit3b9fcfcffab8f927a01877804fa6ac5bbca34c7a (patch)
tree3aca2d329ff5a40fd1cb5190ab248e6a54f5eb70
parent4d77c65a9e57e1d1a459c44411930c7a892835fd (diff)
patch 8.1.0294: MS-Windows: sometimes uses short directory namev8.1.0294
Problem: MS-Windows: sometimes uses short directory name. Solution: Expand to long file name with correct caps. (Nobuhiro Takasaki, closes #3334)
-rw-r--r--src/os_win32.c19
-rw-r--r--src/version.c2
2 files changed, 19 insertions, 2 deletions
diff --git a/src/os_win32.c b/src/os_win32.c
index 85c8a57d11..8065ee858b 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -3108,6 +3108,8 @@ mch_dirname(
char_u *buf,
int len)
{
+ char_u abuf[_MAX_PATH + 1];
+
/*
* Originally this was:
* return (getcwd(buf, len) != NULL ? OK : FAIL);
@@ -3121,7 +3123,13 @@ mch_dirname(
if (GetCurrentDirectoryW(_MAX_PATH, wbuf) != 0)
{
- char_u *p = utf16_to_enc(wbuf, NULL);
+ WCHAR wcbuf[_MAX_PATH + 1];
+ char_u *p;
+
+ if (GetLongPathNameW(wbuf, wcbuf, _MAX_PATH) != 0)
+ p = utf16_to_enc(wcbuf, NULL);
+ else
+ p = utf16_to_enc(wbuf, NULL);
if (p != NULL)
{
@@ -3133,7 +3141,14 @@ mch_dirname(
return FAIL;
}
#endif
- return (GetCurrentDirectory(len, (LPSTR)buf) != 0 ? OK : FAIL);
+ if (GetCurrentDirectory(len, (LPSTR)buf) == 0)
+ return FAIL;
+ if (GetLongPathNameA((LPSTR)buf, (LPSTR)abuf, _MAX_PATH) == 0)
+ // return the short path name
+ return OK;
+
+ vim_strncpy(abuf, buf, len - 1);
+ return OK;
}
/*
diff --git a/src/version.c b/src/version.c
index c5975e8b32..8cf1ad45f4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 294,
+/**/
293,
/**/
292,