include: posix: Split dirent.h from unistd.h
From POSIX http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html """ The <dirent.h> header shall define the following type: DIR ... also define the structure dirent """ etc. Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
260fbc4249
commit
c152ebd634
4 changed files with 39 additions and 11 deletions
37
include/posix/dirent.h
Normal file
37
include/posix/dirent.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
||||
#define ZEPHYR_INCLUDE_POSIX_DIRENT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include "sys/types.h"
|
||||
|
||||
#ifdef CONFIG_POSIX_FS
|
||||
#include <fs.h>
|
||||
|
||||
typedef struct fs_dir_t DIR;
|
||||
|
||||
struct dirent {
|
||||
unsigned int d_ino;
|
||||
char d_name[PATH_MAX + 1];
|
||||
};
|
||||
|
||||
/* Directory related operations */
|
||||
extern DIR *opendir(const char *dirname);
|
||||
extern int closedir(DIR *dirp);
|
||||
extern struct dirent *readdir(DIR *dirp);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ZEPHYR_INCLUDE_POSIX_DIRENT_H_ */
|
|
@ -16,14 +16,8 @@ extern "C" {
|
|||
#ifdef CONFIG_POSIX_FS
|
||||
#include <fs.h>
|
||||
|
||||
typedef struct fs_dir_t DIR;
|
||||
typedef unsigned int mode_t;
|
||||
|
||||
struct dirent {
|
||||
unsigned int d_ino;
|
||||
char d_name[PATH_MAX + 1];
|
||||
};
|
||||
|
||||
/* File related operations */
|
||||
extern int open(const char *name, int flags);
|
||||
extern int close(int file);
|
||||
|
@ -31,11 +25,6 @@ extern ssize_t write(int file, char *buffer, unsigned int count);
|
|||
extern ssize_t read(int file, char *buffer, unsigned int count);
|
||||
extern int lseek(int file, int offset, int whence);
|
||||
|
||||
/* Directory related operations */
|
||||
extern DIR *opendir(const char *dirname);
|
||||
extern int closedir(DIR *dirp);
|
||||
extern struct dirent *readdir(DIR *dirp);
|
||||
|
||||
/* File System related operations */
|
||||
extern int rename(const char *old, const char *newp);
|
||||
extern int unlink(const char *path);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <limits.h>
|
||||
#include <posix/pthread.h>
|
||||
#include <posix/unistd.h>
|
||||
#include <posix/dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
BUILD_ASSERT_MSG(PATH_MAX > MAX_FILE_NAME,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <posix/unistd.h>
|
||||
#include <posix/dirent.h>
|
||||
#include "test_fs.h"
|
||||
|
||||
extern int test_file_write(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue