فهرست منبع

[rtlibc] remove libc_dirent.h

Meco Man 3 سال پیش
والد
کامیت
aab382c32e
5فایلهای تغییر یافته به همراه24 افزوده شده و 48 حذف شده
  1. 6 13
      components/dfs/include/dfs.h
  2. 0 8
      components/dfs/include/dfs_posix.h
  3. 18 9
      components/libc/compilers/common/dirent.h
  4. 0 17
      include/libc/libc_dirent.h
  5. 0 1
      include/rtlibc.h

+ 6 - 13
components/dfs/include/dfs.h

@@ -16,10 +16,13 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <time.h>
-#include <rtthread.h>
+#include <sys/time.h>
 #include <rtdevice.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef DFS_FILESYSTEMS_MAX
 #define DFS_FILESYSTEMS_MAX     2
 #endif
@@ -63,9 +66,7 @@
 #define DFS_F_EOF               0x04000000
 #define DFS_F_ERR               0x08000000
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <dirent.h>
 
 struct statfs
 {
@@ -74,14 +75,6 @@ struct statfs
     size_t f_bfree;   /* free blocks in file system */
 };
 
-struct dirent
-{
-    uint8_t d_type;           /* The type of the file */
-    uint8_t d_namlen;         /* The length of the not including the terminating null file name */
-    uint16_t d_reclen;        /* length of this record */
-    char d_name[DFS_PATH_MAX];   /* The null-terminated file name */
-};
-
 struct dfs_fdtable
 {
     uint32_t maxfd;

+ 0 - 8
components/dfs/include/dfs_posix.h

@@ -21,14 +21,6 @@
 extern "C" {
 #endif
 
-typedef struct
-{
-    int fd;     /* directory file */
-    char buf[512];
-    int num;
-    int cur;
-} DIR;
-
 /* directory api*/
 int mkdir(const char *path, mode_t mode);
 DIR *opendir(const char *name);

+ 18 - 9
components/libc/compilers/common/dirent.h

@@ -6,10 +6,14 @@
  * Change Logs:
  * Date           Author       Notes
  */
-#ifndef __RTT_DIRENT_H__
-#define __RTT_DIRENT_H__
+#ifndef __DIRENT_H__
+#define __DIRENT_H__
 
-#include <rtthread.h>
+#include <rtdef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /*
 * dirent.h - format of directory entries
@@ -26,27 +30,32 @@
 #define DT_REG          0x01
 #define DT_DIR          0x02
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
 #ifndef HAVE_DIR_STRUCTURE
+#define HAVE_DIR_STRUCTURE
 typedef struct
 {
     int fd;                         /* directory file */
     char buf[512];
     int num;
     int cur;
-} DIR;
+}DIR;
 #endif
 
 #ifndef HAVE_DIRENT_STRUCTURE
+#define HAVE_DIRENT_STRUCTURE
+
+#ifdef DFS_PATH_MAX
+#define DIRENT_NAME_MAX    DFS_PATH_MAX
+#else
+#define DIRENT_NAME_MAX    256
+#endif
+
 struct dirent
 {
     rt_uint8_t  d_type;             /* The type of the file */
     rt_uint8_t  d_namlen;           /* The length of the not including the terminating null file name */
     rt_uint16_t d_reclen;           /* length of this record */
-    char d_name[256];               /* The null-terminated file name */
+    char d_name[DIRENT_NAME_MAX];   /* The null-terminated file name */
 };
 #endif
 

+ 0 - 17
include/libc/libc_dirent.h

@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date           Author       Notes
- */
-
-#ifndef LIBC_DIRENT_H__
-#define LIBC_DIRENT_H__
-
-#define DT_UNKNOWN           0x00
-#define DT_REG               0x01
-#define DT_DIR               0x02
-
-#endif

+ 0 - 1
include/rtlibc.h

@@ -14,7 +14,6 @@
 /* definitions for libc if toolchain has no these definitions */
 #include "libc/libc_stat.h"
 #include "libc/libc_fcntl.h"
-#include "libc/libc_dirent.h"
 
 #ifndef RT_USING_LIBC
 #if defined(__ARMCC_VERSION) || defined(__IAR_SYSTEMS_ICC__)