Mercurial > vim
diff src/os_unix.c @ 7629:befbed72da87 v7.4.1114
commit https://github.com/vim/vim/commit/43a34f9f74fdce462fa250baab620264c28b6165
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 17 15:56:34 2016 +0100
patch 7.4.1114
Problem: delete() does not work well with symbolic links.
Solution: Recognize symbolik links.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 17 Jan 2016 16:00:05 +0100 |
parents | 15eefe1b0dad |
children | 6069f43cea4e |
line wrap: on
line diff
--- a/src/os_unix.c +++ b/src/os_unix.c @@ -2994,7 +2994,7 @@ mch_hide(name) } /* - * return TRUE if "name" is a directory + * return TRUE if "name" is a directory or a symlink to a directory * return FALSE if "name" is not a directory * return FALSE for error */ @@ -3015,6 +3015,28 @@ mch_isdir(name) #endif } +/* + * return TRUE if "name" is a directory, NOT a symlink to a directory + * return FALSE if "name" is not a directory + * return FALSE for error + */ + int +mch_isrealdir(name) + char_u *name; +{ + struct stat statb; + + if (*name == NUL) /* Some stat()s don't flag "" as an error. */ + return FALSE; + if (lstat((char *)name, &statb)) + return FALSE; +#ifdef _POSIX_SOURCE + return (S_ISDIR(statb.st_mode) ? TRUE : FALSE); +#else + return ((statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE); +#endif +} + static int executable_file __ARGS((char_u *name)); /*