• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <stddef.h>
18 #include <stdint.h>
19 
20 /**
21  * This header file provides POSIX-compatible definitions of directory
22  * access functions and related data types.
23  * See http://pubs.opengroup.org/onlinepubs/7908799/xsh/dirent.h.html
24  * for reference.
25  */
26 
27 /**
28  * @brief Opaque directory structure
29  */
30 typedef struct {
31     uint16_t dd_vfs_idx; /*!< VFS index, not to be used by applications */
32     uint16_t dd_rsv;     /*!< field reserved for future extension */
33     /* remaining fields are defined by VFS implementation */
34 } DIR;
35 
36 /**
37  * @brief Directory entry structure
38  */
39 struct dirent {
40     int d_ino;          /*!< file number */
41     uint8_t d_type;     /*!< not defined in POSIX, but present in BSD and Linux */
42 #define DT_UNKNOWN  0
43 #define DT_REG      1
44 #define DT_DIR      2
45 #if __BSD_VISIBLE
46 #define MAXNAMLEN 255
47     char d_name[MAXNAMLEN+1];   /*!< zero-terminated file name */
48 #else
49     char d_name[256];
50 #endif
51 };
52 
53 DIR* opendir(const char* name);
54 struct dirent* readdir(DIR* pdir);
55 long telldir(DIR* pdir);
56 void seekdir(DIR* pdir, long loc);
57 void rewinddir(DIR* pdir);
58 int closedir(DIR* pdir);
59 int readdir_r(DIR* pdir, struct dirent* entry, struct dirent** out_dirent);
60