| line |
true |
false |
branch |
|
19
|
0 |
6587 |
int (*statfn)(const char *, struct stat *) = (flags & B_FIND_FOLLOW_SYMLINKS)? stat: lstat; |
|
32
|
0 |
87 |
if ((dir = malloc(sizeof(*dir))) == NULL) { |
|
36
|
0 |
87 |
if ((dir->dp = opendir(path->str)) == NULL) { |
|
40
|
0 |
87 |
if ((dir->path = b_string_dup(path)) == NULL) { |
|
57
|
87 |
0 |
if (item->dp) { |
|
63
|
0 |
87 |
if (item == NULL) return; |
|
86
|
87 |
299 |
if ((entry = readdir(dir->dp)) == NULL) { |
|
90
|
0 |
299 |
if ((item = malloc(sizeof(*item))) == NULL) { |
|
94
|
0 |
299 |
if ((item->path = b_string_dup(dir->path)) == NULL) { |
|
98
|
0 |
299 |
if ((item->name = b_string_new(entry->d_name)) == NULL) { |
|
105
|
299 |
0 |
if (strcmp(item->path->str, "/") != 0) { |
|
106
|
0 |
299 |
if (b_string_append_str(item->path, "/") == NULL) { |
|
111
|
0 |
299 |
if (b_string_append_str(item->path, entry->d_name) == NULL) { |
|
132
|
0 |
299 |
if (item == NULL) return; |
|
150
|
42 |
41 |
if (strcmp(path->str, member_name->str) != 0) { |
|
151
|
0 |
42 |
if ((new_member_name = b_string_dup(member_name)) == NULL) { |
|
155
|
0 |
42 |
if (b_string_append_str(new_member_name, current->str + b_string_len(path)) == NULL) { |
|
184
|
0 |
6587 |
if (flags & B_FIND_FOLLOW_SYMLINKS) { |
|
188
|
0 |
6587 |
if ((clean_path = b_path_clean(path)) == NULL) { |
|
192
|
0 |
6587 |
if ((clean_member_name = b_path_clean(member_name)) == NULL) { |
|
196
|
0 |
6587 |
if ((dirs = b_stack_new(0)) == NULL) { |
|
202
|
0 |
6587 |
if (b_stat(clean_path, &st, flags) < 0) { |
|
212
|
6556 |
31 |
if ((st.st_mode & S_IFMT) == S_IFREG) { |
|
213
|
0 |
6556 |
if ((fd = open(clean_path->str, oflags)) < 0) { |
|
216
|
0 |
6556 |
if (fcntl(fd, F_SETFL, oflags & ~O_NONBLOCK)) // previously clear_nonblock, however we know oflags so we can do it outselves |
|
222
|
6556 |
31 |
if (fd > 0) { |
|
227
|
0 |
6587 |
if (res == 0) { |
|
229
|
8 |
6579 |
} else if (res < 0) { |
|
233
|
6548 |
31 |
if ((st.st_mode & S_IFMT) != S_IFDIR) { |
|
237
|
0 |
31 |
if ((dir = b_dir_open(clean_path)) == NULL) { |
|
238
|
0 |
0 |
if (err) { |
|
245
|
0 |
31 |
if (b_stack_push(dirs, dir) == NULL) { |
|
257
|
31 |
386 |
if (cwd == NULL) { |
|
261
|
87 |
299 |
if ((item = b_dir_read(cwd, flags)) == NULL) { |
|
264
|
87 |
0 |
if (oldcwd) { |
|
271
|
212 |
87 |
if (strcmp(item->name->str, ".") == 0 || strcmp(item->name->str, "..") == 0) { |
|
|
87 |
125 |
if (strcmp(item->name->str, ".") == 0 || strcmp(item->name->str, "..") == 0) { |
|
280
|
119 |
6 |
if (builder->match != NULL && lafe_excluded(builder->match, (const char *)item->path->str)) { |
|
|
42 |
77 |
if (builder->match != NULL && lafe_excluded(builder->match, (const char *)item->path->str)) { |
|
284
|
0 |
83 |
if ((item_fd = open(item->path->str, oflags)) < 0) { |
|
298
|
0 |
0 |
if ((oflags & O_NOFOLLOW) && (errno == ELOOP || errno == EMLINK || errno == EFTYPE)) { |
|
|
0 |
0 |
if ((oflags & O_NOFOLLOW) && (errno == ELOOP || errno == EMLINK || errno == EFTYPE)) { |
|
|
0 |
0 |
if ((oflags & O_NOFOLLOW) && (errno == ELOOP || errno == EMLINK || errno == EFTYPE)) { |
|
|
0 |
0 |
if ((oflags & O_NOFOLLOW) && (errno == ELOOP || errno == EMLINK || errno == EFTYPE)) { |
|
299
|
0 |
0 |
if (lstat(item->path->str, &item_st) < 0) { |
|
300
|
0 |
0 |
if (err) { |
|
307
|
0 |
0 |
if( flags & B_FIND_IGNORE_SOCKETS ) { |
|
308
|
0 |
0 |
if (stat(item->path->str, &item_st) < 0) { |
|
309
|
0 |
0 |
if (err) { |
|
314
|
0 |
0 |
if( err && (item_st.st_mode & S_IFMT) != S_IFSOCK ) { |
|
|
0 |
0 |
if( err && (item_st.st_mode & S_IFMT) != S_IFSOCK ) { |
|
320
|
0 |
0 |
if (err) { |
|
328
|
0 |
83 |
if (fcntl(fd, F_SETFL, oflags & ~O_NONBLOCK)) // previously clear_nonblock, however we know oflags so we can do it outselves |
|
330
|
0 |
83 |
if (fstat(item_fd, &item_st) < 0) { |
|
331
|
0 |
0 |
if (err) { |
|
345
|
41 |
42 |
res = callback(builder, item->path, new_member_name? new_member_name: item->path, &item_st, item_fd); |
|
349
|
0 |
83 |
if (res == 0) { |
|
351
|
0 |
83 |
} else if (res < 0) { |
|
352
|
0 |
0 |
if (err && !b_error_fatal(err)) { |
|
|
0 |
0 |
if (err && !b_error_fatal(err)) { |
|
359
|
56 |
27 |
if ((item_st.st_mode & S_IFMT) == S_IFDIR) { |
|
362
|
0 |
56 |
if ((newdir = b_dir_open(item->path)) == NULL) { |
|
363
|
0 |
0 |
if (err) { |
|
367
|
0 |
0 |
if (errno == EACCES) { |
|
374
|
56 |
0 |
if (b_stack_push(dirs, newdir) == NULL) { |
|
382
|
83 |
216 |
if (item_fd > 0) { |
|
392
|
0 |
0 |
if (item_fd > 0) { |
|
413
|
8 |
0 |
if (fd > 0) { |