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
parent 637efc3456
commit a50f9fc5fe

7
dir.c
View File

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