Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
7628:d74db83fa956 | 7629:befbed72da87 |
---|---|
2992 { | 2992 { |
2993 /* can't hide a file */ | 2993 /* can't hide a file */ |
2994 } | 2994 } |
2995 | 2995 |
2996 /* | 2996 /* |
2997 * return TRUE if "name" is a directory | 2997 * return TRUE if "name" is a directory or a symlink to a directory |
2998 * return FALSE if "name" is not a directory | 2998 * return FALSE if "name" is not a directory |
2999 * return FALSE for error | 2999 * return FALSE for error |
3000 */ | 3000 */ |
3001 int | 3001 int |
3002 mch_isdir(name) | 3002 mch_isdir(name) |
3005 struct stat statb; | 3005 struct stat statb; |
3006 | 3006 |
3007 if (*name == NUL) /* Some stat()s don't flag "" as an error. */ | 3007 if (*name == NUL) /* Some stat()s don't flag "" as an error. */ |
3008 return FALSE; | 3008 return FALSE; |
3009 if (stat((char *)name, &statb)) | 3009 if (stat((char *)name, &statb)) |
3010 return FALSE; | |
3011 #ifdef _POSIX_SOURCE | |
3012 return (S_ISDIR(statb.st_mode) ? TRUE : FALSE); | |
3013 #else | |
3014 return ((statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE); | |
3015 #endif | |
3016 } | |
3017 | |
3018 /* | |
3019 * return TRUE if "name" is a directory, NOT a symlink to a directory | |
3020 * return FALSE if "name" is not a directory | |
3021 * return FALSE for error | |
3022 */ | |
3023 int | |
3024 mch_isrealdir(name) | |
3025 char_u *name; | |
3026 { | |
3027 struct stat statb; | |
3028 | |
3029 if (*name == NUL) /* Some stat()s don't flag "" as an error. */ | |
3030 return FALSE; | |
3031 if (lstat((char *)name, &statb)) | |
3010 return FALSE; | 3032 return FALSE; |
3011 #ifdef _POSIX_SOURCE | 3033 #ifdef _POSIX_SOURCE |
3012 return (S_ISDIR(statb.st_mode) ? TRUE : FALSE); | 3034 return (S_ISDIR(statb.st_mode) ? TRUE : FALSE); |
3013 #else | 3035 #else |
3014 return ((statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE); | 3036 return ((statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE); |