Debian Codegraph @

src/lib/util/dir.h

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2019 Red Hat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _DIR_H_
22 #define _DIR_H_
23
24 #include "common/errno_t.h"
25
26 /* List files. */
27 #define DIR_LIST_FILES 0x0001
28
29 /* List directories. */
30 #define DIR_LIST_DIRS 0x0002
31
32 /* Use fully qualified paths in the output. */
33 #define DIR_LIST_FULL_PATH 0x0004
34
35 /* Sort listing by creation time. */
36 #define DIR_LIST_SORT_BY_CTIME 0x0010
37
38 /**
39 * List items in a directory.
40 *
41 * @param path Directory to list.
42 * @param flags See DIR_LIST_* macros.
43 * @param _items NULL-terminated string array that hold the directory items.
44 * @param _dirfd If not NULL an open file descriptor of this directory is
45 * stored here.
46 *
47 * @return EOK on success, ENOENT if the directory was not found, other
48 * errno code on failure.
49 */
50 errno_t
51 dir_list(const char *path,
52 uint32_t flags,
53 char ***_items,
54 int *_dirfd);
55
56 /**
57 * Recursively remove (non-empty) directory.
58 *
59 * @param path Path to the directory.
60 *
61 * @return EOK on success, other errno code on failure.
62 */
63 errno_t
64 dir_remove(const char *path);
65
66 #endif /* _DIR_H_ */