vim-patch:9.1.0499: MS-Windows: doesn't handle symlinks properly (#29400)

Problem:  MS-Windows: doesn't handle symlinks properly
          (Timothy Madden)
Solution: Implement lstat() on MS-Windows
          (author)

lstat() differs from stat() in how it handles symbolic links, the former
doesn't resolve the symlink while the latter does so.

Implement a simple yet effective fallback using Win32 APIs.

fixes vim/vim#14933
closes: vim/vim#15014

23c5ebeb95

Co-authored-by: LemonBoy <thatlemon@gmail.com>
Co-authored-by: K.Takata <kentkt@csc.jp>
This commit is contained in:
zeertzjq 2024-06-19 06:32:02 +08:00 committed by GitHub
parent 6012f79557
commit a2d510e101
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3475,6 +3475,29 @@ func Test_glob2()
endif
endfunc
func Test_glob_symlinks()
call writefile([], 'Xglob1')
if has("win32")
silent !mklink XglobBad DoesNotExist
if v:shell_error
throw 'Skipped: cannot create symlinks'
endif
silent !mklink XglobOk Xglob1
else
silent !ln -s DoesNotExist XglobBad
silent !ln -s Xglob1 XglobOk
endif
" The broken symlink is excluded when alllinks is false.
call assert_equal(['Xglob1', 'XglobBad', 'XglobOk'], sort(glob('Xglob*', 0, 1, 1)))
call assert_equal(['Xglob1', 'XglobOk'], sort(glob('Xglob*', 0, 1, 0)))
call delete('Xglob1')
call delete('XglobBad')
call delete('XglobOk')
endfunc
" Test for browse()
func Test_browse()
CheckFeature browse