Tizen RT Libs&Environment  v1.0 D5
dirent.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/dirent.h
20  *
21  * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
60 
63 #ifndef __INCLUDE_DIRENT_H
64 #define __INCLUDE_DIRENT_H
65 
66 /****************************************************************************
67  * Included Files
68  ****************************************************************************/
69 
70 #include <tinyara/config.h>
71 
72 #include <sys/types.h>
73 #include <stdint.h>
74 #include <limits.h>
75 
76 /****************************************************************************
77  * Pre-processor Definitions
78  ****************************************************************************/
79 
80 /* File type code for the d_type field in dirent struct.
81  * Note that because of the simplified filesystem organization
82  * of TinyAra, an inode can be BOTH a file and a directory
83  */
84 
85 #define DTYPE_FILE 0x01
86 #define DTYPE_CHR 0x02
87 #define DTYPE_BLK 0x04
88 #define DTYPE_DIRECTORY 0x08
89 
90 #define DIRENT_ISFILE(dtype) (((dtype) & DTYPE_FILE) != 0)
91 #define DIRENT_ISCHR(dtype) (((dtype) & DTYPE_CHR) != 0)
92 #define DIRENT_ISBLK(dtype) (((dtype) & DTYPE_BLK) != 0)
93 #define DIRENT_ISDIRECTORY(dtype) (((dtype) & DTYPE_DIRECTORY) != 0)
94 
95 /****************************************************************************
96  * Public Type Definitions
97  ****************************************************************************/
98 
99 /* The POSIX specification requires that the caller of readdir_r provide
100  * storage "large enough for a dirent with the d_name member and an array
101  * of char containing at least {NAME_MAX} plus one elements.
102  */
103 
104 struct dirent {
105  uint8_t d_type; /* type of file */
106  char d_name[NAME_MAX + 1]; /* filename */
107 };
108 
109 typedef void DIR;
110 
111 /****************************************************************************
112  * Public Variables
113  ****************************************************************************/
114 
115 /****************************************************************************
116  * Public Function Prototypes
117  ****************************************************************************/
118 
119 #undef EXTERN
120 #if defined(__cplusplus)
121 #define EXTERN extern "C"
122 extern "C" {
123 #else
124 #define EXTERN extern
125 #endif
126 
127 /* POSIX-like File System Interfaces */
128 
135 int closedir(FAR DIR *dirp);
142 FAR DIR *opendir(FAR const char *path);
149 FAR struct dirent *readdir(FAR DIR *dirp);
155 int readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result);
162 void rewinddir(FAR DIR *dirp);
170 void seekdir(FAR DIR *dirp, off_t loc);
178 off_t telldir(FAR DIR *dirp);
179 
180 #undef EXTERN
181 #if defined(__cplusplus)
182 }
183 #endif
184 
185 #endif /* __INCLUDE_DIRENT_H */
186 
int closedir(FAR DIR *dirp)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR struct dirent * readdir(FAR DIR *dirp)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
void DIR
Definition: dirent.h:109
Definition: dirent.h:104
off_t telldir(FAR DIR *dirp)
gets the current location associated with the directory stream
int readdir_r(FAR DIR *dirp, FAR struct dirent *entry, FAR struct dirent **result)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
char d_name[NAME_MAX+1]
Definition: dirent.h:106
void rewinddir(FAR DIR *dirp)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR DIR * opendir(FAR const char *path)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
void seekdir(FAR DIR *dirp, off_t loc)
sets the location in the directory stream from which the next readdir() call will start...
uint8_t d_type
Definition: dirent.h:105