]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
db2df898 MP |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2010 Lennart Poettering | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ***/ | |
22 | ||
23 | #include <dirent.h> | |
4c89c718 MP |
24 | #include <errno.h> |
25 | #include <stdbool.h> | |
db2df898 | 26 | |
4c89c718 | 27 | #include "macro.h" |
db2df898 MP |
28 | #include "path-util.h" |
29 | ||
30 | int dirent_ensure_type(DIR *d, struct dirent *de); | |
31 | ||
32 | bool dirent_is_file(const struct dirent *de) _pure_; | |
33 | bool dirent_is_file_with_suffix(const struct dirent *de, const char *suffix) _pure_; | |
34 | ||
81c58355 MB |
35 | struct dirent* readdir_no_dot(DIR *dirp); |
36 | ||
db2df898 MP |
37 | #define FOREACH_DIRENT(de, d, on_error) \ |
38 | for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d)) \ | |
39 | if (!de) { \ | |
40 | if (errno > 0) { \ | |
41 | on_error; \ | |
42 | } \ | |
43 | break; \ | |
aa27b158 | 44 | } else if (hidden_or_backup_file((de)->d_name)) \ |
db2df898 MP |
45 | continue; \ |
46 | else | |
47 | ||
48 | #define FOREACH_DIRENT_ALL(de, d, on_error) \ | |
49 | for (errno = 0, de = readdir(d);; errno = 0, de = readdir(d)) \ | |
50 | if (!de) { \ | |
51 | if (errno > 0) { \ | |
52 | on_error; \ | |
53 | } \ | |
54 | break; \ | |
55 | } else |