posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
dirent.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
16#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_
17#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_
18
19#include <limits.h>
20#include <sys/types.h>
21
22#include <zephyr/toolchain.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28#if !defined(NAME_MAX) && defined(_XOPEN_SOURCE)
30#define NAME_MAX _XOPEN_NAME_MAX
31#endif
32
33#if !defined(NAME_MAX) && defined(_POSIX_C_SOURCE)
35#define NAME_MAX _POSIX_NAME_MAX
36#endif
37
38struct zvfs_dirstream;
47typedef struct zvfs_dirstream DIR;
48
49#if !defined(_DIRENT_DECLARED) && !defined(__dirent_defined)
57struct dirent {
58 ino_t d_ino;
59 char d_name[255 + 1];
60};
61#define _DIRENT_DECLARED
62#define __dirent_defined
63#endif
64
65#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
74int alphasort(const struct dirent **d1, const struct dirent **d2);
75#endif
76
84int closedir(DIR *dirp);
85
86#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
94int dirfd(DIR *dirp);
95#endif
96
104DIR *fdopendir(int fd);
105
113DIR *opendir(const char *dirname);
114
121struct dirent *readdir(DIR *dirp);
122
123#if (_POSIX_C_SOURCE >= 199506L) || (_XOPEN_SOURCE >= 500)
133int readdir_r(DIR *ZRESTRICT dirp, struct dirent *ZRESTRICT entry,
134 struct dirent **ZRESTRICT result);
135#endif
136
143void rewinddir(DIR *dirp);
144
145#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700)
156int scandir(const char *dir, struct dirent ***namelist, int (*sel)(const struct dirent *),
157 int (*compar)(const struct dirent **, const struct dirent **));
158#endif
159
160#if defined(_XOPEN_SOURCE)
168void seekdir(DIR *dirp, long loc);
169
177long telldir(DIR *dirp);
178#endif
179
180
181#ifdef __cplusplus
182}
183#endif
184
185#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */
struct zvfs_dirstream DIR
Directory stream type.
Definition dirent.h:47
long telldir(DIR *dirp)
Get the current position of a directory stream (XSI extension).
DIR * fdopendir(int fd)
Open a directory stream for a directory identified by a file descriptor.
int alphasort(const struct dirent **d1, const struct dirent **d2)
Compare two directory entries alphabetically (for use with scandir()).
int readdir_r(DIR *ZRESTRICT dirp, struct dirent *ZRESTRICT entry, struct dirent **ZRESTRICT result)
Read a directory entry into a caller-supplied buffer (thread-safe).
void seekdir(DIR *dirp, long loc)
Set the position of a directory stream (XSI extension).
struct dirent * readdir(DIR *dirp)
Read the next entry from a directory stream.
int dirfd(DIR *dirp)
Get the file descriptor for an open directory stream.
int closedir(DIR *dirp)
Close a directory stream.
int scandir(const char *dir, struct dirent ***namelist, int(*sel)(const struct dirent *), int(*compar)(const struct dirent **, const struct dirent **))
Scan a directory, optionally filtering and sorting the entries.
void rewinddir(DIR *dirp)
Reset a directory stream to the beginning.
DIR * opendir(const char *dirname)
Open a directory stream for a named directory.
Directory entry returned by readdir().
Definition dirent.h:57
char d_name[255+1]
Filename (null-terminated).
Definition dirent.h:59
ino_t d_ino
File serial number, 0 (untracked).
Definition dirent.h:58
POSIX fundamental types (<sys/types.h>)