-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
posix: include: dirent: rework the dirent.h header
Declare standard functions and split type definitions into sys/dirent.h . Signed-off-by: Chris Friedt <[email protected]>
- Loading branch information
Showing
2 changed files
with
69 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,45 @@ | ||
/* | ||
* Copyright (c) 2018 Intel Corporation | ||
* Copyright (c) 2024 Tenstorrent AI ULC | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_ | ||
#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_ | ||
|
||
#include <limits.h> | ||
|
||
#include <zephyr/posix/posix_types.h> | ||
|
||
#ifdef CONFIG_POSIX_FILE_SYSTEM | ||
#include <zephyr/fs/fs.h> | ||
#include <zephyr/posix/sys/dirent.h> | ||
#include <zephyr/toolchain.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef void DIR; | ||
|
||
struct dirent { | ||
unsigned int d_ino; | ||
char d_name[PATH_MAX + 1]; | ||
}; | ||
|
||
/* Directory related operations */ | ||
DIR *opendir(const char *dirname); | ||
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700) | ||
int alphasort(const struct dirent **d1, const struct dirent **d2); | ||
#endif | ||
int closedir(DIR *dirp); | ||
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700) | ||
int dirfd(DIR *dirp); | ||
#endif | ||
DIR *fdopendir(int fd); | ||
DIR *opendir(const char *dirname); | ||
struct dirent *readdir(DIR *dirp); | ||
#if (_POSIX_C_SOURCE >= 199506L) || (_XOPEN_SOURCE >= 500) | ||
int readdir_r(DIR *ZRESTRICT dirp, struct dirent *ZRESTRICT entry, | ||
struct dirent **ZRESTRICT result); | ||
#endif | ||
void rewinddir(DIR *dirp); | ||
#if (_POSIX_C_SOURCE >= 200809L) || (_XOPEN_SOURCE >= 700) | ||
int scandir(const char *dir, struct dirent ***namelist, int (*sel)(const struct dirent *), | ||
int (*compar)(const struct dirent **, const struct dirent **)); | ||
#endif | ||
#if defined(_XOPEN_SOURCE) | ||
void seekdir(DIR *dirp, long loc); | ||
long telldir(DIR *dirp); | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* CONFIG_POSIX_FILE_SYSTEM */ | ||
|
||
#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */ | ||
#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2024 Tenstorrent AI ULC | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ | ||
#define ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ | ||
|
||
#include <limits.h> | ||
|
||
#include <zephyr/posix/posix_features.h> | ||
|
||
#ifndef PATH_MAX | ||
#ifdef _XOPEN_SOURCE | ||
#define PATH_MAX _XOPEN_PATH_MAX | ||
#endif | ||
#endif | ||
|
||
#ifndef PATH_MAX | ||
#ifdef _POSIX_C_SOURCE | ||
#define PATH_MAX _POSIX_PATH_MAX | ||
#endif | ||
#endif | ||
|
||
#ifndef PATH_MAX | ||
#define PATH_MAX 31 | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef void DIR; | ||
|
||
struct dirent { | ||
unsigned int d_ino; | ||
char d_name[PATH_MAX + 1]; | ||
}; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_POSIX_SYS_DIRENT_H_ */ |