mirror of
https://github.com/git/git.git
synced 2024-11-28 12:34:08 +08:00
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:
parent
637efc3456
commit
a50f9fc5fe
7
dir.c
7
dir.c
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user