@matheusbsbs / matheus-bagliano / commits / c470701a98
Fork 0

Use fstat instead of fseek

Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>

Jonas Fonseca committed Aug 28, 2006 at 01:55 UTC c470701a98700533024b1864b789d4fc17e5e823
1 file changed +3 -5
dir.c
+3 -5
@@ -112,17 +112,15 @@ static int add_excludes_from_file_1(const char *fname,
112 int baselen,
113 struct exclude_list *which)
114 {
115 + struct stat st;
116 int fd, i;
117 long size;
118 char *buf, *entry;
119
120 fd = open(fname, O_RDONLY);
120 - if (fd < 0)
121 + if (fd < 0 || fstat(fd, &st) < 0)
122 goto err;
122 - size = lseek(fd, 0, SEEK_END);
123 - if (size < 0)
124 - goto err;
125 - lseek(fd, 0, SEEK_SET);
123 + size = st.st_size;
124 if (size == 0) {
125 close(fd);
126 return 0;