]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
a0956174 LP |
2 | #pragma once |
3 | ||
a0956174 | 4 | #include <dirent.h> |
11c3a366 TA |
5 | #include <errno.h> |
6 | #include <stdbool.h> | |
a0956174 | 7 | |
11c3a366 | 8 | #include "macro.h" |
93cc7779 | 9 | #include "path-util.h" |
a0956174 | 10 | |
21d46382 LP |
11 | int stat_mode_to_dirent_type(mode_t mode); |
12 | ||
a0956174 LP |
13 | bool dirent_is_file(const struct dirent *de) _pure_; |
14 | bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_; | |
15 | ||
98f7a4c8 YW |
16 | struct dirent *readdir_ensure_type(DIR *d); |
17 | struct dirent *readdir_no_dot(DIR *dirp); | |
48d7c648 | 18 | |
a0956174 | 19 | #define FOREACH_DIRENT(de, d, on_error) \ |
f565b867 | 20 | for (de = readdir_ensure_type(d);; de = readdir_ensure_type(d)) \ |
a0956174 LP |
21 | if (!de) { \ |
22 | if (errno > 0) { \ | |
23 | on_error; \ | |
24 | } \ | |
25 | break; \ | |
55cdd057 | 26 | } else if (hidden_or_backup_file((de)->d_name)) \ |
a0956174 LP |
27 | continue; \ |
28 | else | |
29 | ||
30 | #define FOREACH_DIRENT_ALL(de, d, on_error) \ | |
f565b867 | 31 | for (de = readdir_ensure_type(d);; de = readdir_ensure_type(d)) \ |
a0956174 LP |
32 | if (!de) { \ |
33 | if (errno > 0) { \ | |
34 | on_error; \ | |
35 | } \ | |
36 | break; \ | |
37 | } else |