Mercurial > vim
changeset 14561:3ea4a48213e6 v8.1.0294
patch 8.1.0294: MS-Windows: sometimes uses short directory name
commit https://github.com/vim/vim/commit/3b9fcfcffab8f927a01877804fa6ac5bbca34c7a
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Aug 18 20:20:27 2018 +0200
patch 8.1.0294: MS-Windows: sometimes uses short directory name
Problem: MS-Windows: sometimes uses short directory name.
Solution: Expand to long file name with correct caps. (Nobuhiro Takasaki,
closes #3334)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 18 Aug 2018 20:30:06 +0200 |
parents | 8413e66d00a1 |
children | 5d0a0e3e62f2 |
files | src/os_win32.c src/version.c |
diffstat | 2 files changed, 19 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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; } /*