Skip to content

Commit

Permalink
file_exists(): dangling symlinks do exist
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Nov 23, 2007
1 parent 637efc3 commit a50f9fc
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down

0 comments on commit a50f9fc

Please sign in to comment.