file_exists(): dangling symlinks do exist

This function is used to see if a path given by the user does exist
on the filesystem.  A symbolic link that does not point anywhere does
exist but running stat() on it would yield an error, and it incorrectly
said it does not exist.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano 2007-11-18 01:58:16 -08:00
Родитель 637efc3456
Коммит a50f9fc5fe
1 изменённых файлов: 3 добавлений и 4 удалений

7
dir.c
Просмотреть файл

@ -690,11 +690,10 @@ int read_directory(struct dir_struct *dir, const char *path, const char *base, i
return dir->nr;
}
int
file_exists(const char *f)
int file_exists(const char *f)
{
struct stat sb;
return stat(f, &sb) == 0;
struct stat sb;
return lstat(f, &sb) == 0;
}
/*