dirent.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020:
021:
022:
023:
024: #ifndef _DIRENT_H
025: #define _DIRENT_H 1
026:
027: #include <features.h>
028:
029: __BEGIN_DECLS
030:
031: #include <bits/types.h>
032:
033: #ifdef __USE_XOPEN
034: # ifndef __ino_t_defined
035: # ifndef __USE_FILE_OFFSET64
036: typedef __ino_t ino_t;
037: # else
038: typedef __ino64_t ino_t;
039: # endif
040: # define __ino_t_defined
041: # endif
042: # if defined __USE_LARGEFILE64 && !defined __ino64_t_defined
043: typedef __ino64_t ino64_t;
044: # define __ino64_t_defined
045: # endif
046: #endif
047:
048:
049:
050:
051:
052:
053:
054:
055:
056:
057:
058:
059:
060:
061:
062:
063: #include <bits/dirent.h>
064:
065: #if (defined __USE_BSD || defined __USE_MISC) && !defined d_fileno
066: # define d_ino d_fileno
067: #endif
068:
069:
070:
071:
072:
073:
074:
075:
076:
077:
078:
079:
080:
081:
082:
083: #ifdef _DIRENT_HAVE_D_NAMLEN
084: # define _D_EXACT_NAMLEN(d) ((d)->d_namlen)
085: # define _D_ALLOC_NAMLEN(d) (_D_EXACT_NAMLEN (d) + 1)
086: #else
087: # define _D_EXACT_NAMLEN(d) (strlen ((d)->d_name))
088: # ifdef _DIRENT_HAVE_D_RECLEN
089: # define _D_ALLOC_NAMLEN(d) (((char *) (d) + (d)->d_reclen) - &(d)->d_name[0])
090: # else
091: # define _D_ALLOC_NAMLEN(d) (sizeof (d)->d_name > 1 ? sizeof (d)->d_name : \
092: _D_EXACT_NAMLEN (d) + 1)
093: # endif
094: #endif
095:
096:
097: #ifdef __USE_BSD
098:
099: enum
100: {
101: DT_UNKNOWN = 0,
102: # define DT_UNKNOWN DT_UNKNOWN
103: DT_FIFO = 1,
104: # define DT_FIFO DT_FIFO
105: DT_CHR = 2,
106: # define DT_CHR DT_CHR
107: DT_DIR = 4,
108: # define DT_DIR DT_DIR
109: DT_BLK = 6,
110: # define DT_BLK DT_BLK
111: DT_REG = 8,
112: # define DT_REG DT_REG
113: DT_LNK = 10,
114: # define DT_LNK DT_LNK
115: DT_SOCK = 12,
116: # define DT_SOCK DT_SOCK
117: DT_WHT = 14
118: # define DT_WHT DT_WHT
119: };
120:
121:
122: # define IFTODT(mode) (((mode) & 0170000) >> 12)
123: # define DTTOIF(dirtype) ((dirtype) << 12)
124: #endif
125:
126:
127:
128:
129: typedef struct __dirstream DIR;
130:
131:
132:
133:
134:
135:
136: extern DIR *opendir (__const char *__name) __nonnull ((1));
137:
138: #ifdef __USE_XOPEN2K8
139:
140:
141:
142:
143: extern DIR *fdopendir (int __fd);
144: #endif
145:
146:
147:
148:
149:
150:
151: extern int closedir (DIR *__dirp) __nonnull ((1));
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163: #ifndef __USE_FILE_OFFSET64
164: extern struct dirent *readdir (DIR *__dirp) __nonnull ((1));
165: #else
166: # ifdef __REDIRECT
167: extern struct dirent *__REDIRECT (readdir, (DIR *__dirp), readdir64)
168: __nonnull ((1));
169: # else
170: # define readdir readdir64
171: # endif
172: #endif
173:
174: #ifdef __USE_LARGEFILE64
175: extern struct dirent64 *readdir64 (DIR *__dirp) __nonnull ((1));
176: #endif
177:
178: #if defined __USE_POSIX || defined __USE_MISC
179:
180:
181:
182:
183:
184: # ifndef __USE_FILE_OFFSET64
185: extern int readdir_r (DIR *__restrict __dirp,
186: struct dirent *__restrict __entry,
187: struct dirent **__restrict __result)
188: __nonnull ((1, 2, 3));
189: # else
190: # ifdef __REDIRECT
191: extern int __REDIRECT (readdir_r,
192: (DIR *__restrict __dirp,
193: struct dirent *__restrict __entry,
194: struct dirent **__restrict __result),
195: readdir64_r) __nonnull ((1, 2, 3));
196: # else
197: # define readdir_r readdir64_r
198: # endif
199: # endif
200:
201: # ifdef __USE_LARGEFILE64
202: extern int readdir64_r (DIR *__restrict __dirp,
203: struct dirent64 *__restrict __entry,
204: struct dirent64 **__restrict __result)
205: __nonnull ((1, 2, 3));
206: # endif
207: #endif
208:
209:
210: extern void rewinddir (DIR *__dirp) __THROW __nonnull ((1));
211:
212: #if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN
213: # include <bits/types.h>
214:
215:
216: extern void seekdir (DIR *__dirp, long int __pos) __THROW __nonnull ((1));
217:
218:
219: extern long int telldir (DIR *__dirp) __THROW __nonnull ((1));
220: #endif
221:
222: #if defined __USE_BSD || defined __USE_MISC || defined __USE_XOPEN2K8
223:
224:
225: extern int dirfd (DIR *__dirp) __THROW __nonnull ((1));
226:
227: # if defined __OPTIMIZE__ && defined _DIR_dirfd
228: # define dirfd(dirp) _DIR_dirfd (dirp)
229: # endif
230:
231: # if defined __USE_BSD || defined __USE_MISC
232: # ifndef MAXNAMLEN
233:
234: # include <bits/posix1_lim.h>
235:
236:
237: # ifdef NAME_MAX
238: # define MAXNAMLEN NAME_MAX
239: # else
240: # define MAXNAMLEN 255
241: # endif
242: # endif
243: # endif
244:
245: # define __need_size_t
246: # include <stddef.h>
247:
248:
249:
250:
251:
252:
253:
254:
255: # ifndef __USE_FILE_OFFSET64
256: extern int scandir (__const char *__restrict __dir,
257: struct dirent ***__restrict __namelist,
258: int (*__selector) (__const struct dirent *),
259: int (*__cmp) (__const struct dirent **,
260: __const struct dirent **))
261: __nonnull ((1, 2));
262: # else
263: # ifdef __REDIRECT
264: extern int __REDIRECT (scandir,
265: (__const char *__restrict __dir,
266: struct dirent ***__restrict __namelist,
267: int (*__selector) (__const struct dirent *),
268: int (*__cmp) (__const struct dirent **,
269: __const struct dirent **)),
270: scandir64) __nonnull ((1, 2));
271: # else
272: # define scandir scandir64
273: # endif
274: # endif
275:
276: # if defined __USE_GNU && defined __USE_LARGEFILE64
277:
278:
279: extern int scandir64 (__const char *__restrict __dir,
280: struct dirent64 ***__restrict __namelist,
281: int (*__selector) (__const struct dirent64 *),
282: int (*__cmp) (__const struct dirent64 **,
283: __const struct dirent64 **))
284: __nonnull ((1, 2));
285: # endif
286:
287: # ifdef __USE_GNU
288:
289:
290:
291:
292:
293: # ifndef __USE_FILE_OFFSET64
294: extern int scandirat (int __dfd, __const char *__restrict __dir,
295: struct dirent ***__restrict __namelist,
296: int (*__selector) (__const struct dirent *),
297: int (*__cmp) (__const struct dirent **,
298: __const struct dirent **))
299: __nonnull ((2, 3));
300: # else
301: # ifdef __REDIRECT
302: extern int __REDIRECT (scandirat,
303: (int __dfd, __const char *__restrict __dir,
304: struct dirent ***__restrict __namelist,
305: int (*__selector) (__const struct dirent *),
306: int (*__cmp) (__const struct dirent **,
307: __const struct dirent **)),
308: scandirat64) __nonnull ((2, 3));
309: # else
310: # define scandirat scandirat64
311: # endif
312: # endif
313:
314:
315:
316: extern int scandirat64 (int __dfd, __const char *__restrict __dir,
317: struct dirent64 ***__restrict __namelist,
318: int (*__selector) (__const struct dirent64 *),
319: int (*__cmp) (__const struct dirent64 **,
320: __const struct dirent64 **))
321: __nonnull ((2, 3));
322: # endif
323:
324:
325: # ifndef __USE_FILE_OFFSET64
326: extern int alphasort (__const struct dirent **__e1,
327: __const struct dirent **__e2)
328: __THROW __attribute_pure__ __nonnull ((1, 2));
329: # else
330: # ifdef __REDIRECT
331: extern int __REDIRECT_NTH (alphasort,
332: (__const struct dirent **__e1,
333: __const struct dirent **__e2),
334: alphasort64) __attribute_pure__ __nonnull ((1, 2));
335: # else
336: # define alphasort alphasort64
337: # endif
338: # endif
339:
340: # if defined __USE_GNU && defined __USE_LARGEFILE64
341: extern int alphasort64 (__const struct dirent64 **__e1,
342: __const struct dirent64 **__e2)
343: __THROW __attribute_pure__ __nonnull ((1, 2));
344: # endif
345: #endif
346:
347:
348: #if defined __USE_BSD || defined __USE_MISC
349:
350:
351:
352:
353: # ifndef __USE_FILE_OFFSET64
354: extern __ssize_t getdirentries (int __fd, char *__restrict __buf,
355: size_t __nbytes,
356: __off_t *__restrict __basep)
357: __THROW __nonnull ((2, 4));
358: # else
359: # ifdef __REDIRECT
360: extern __ssize_t __REDIRECT_NTH (getdirentries,
361: (int __fd, char *__restrict __buf,
362: size_t __nbytes,
363: __off64_t *__restrict __basep),
364: getdirentries64) __nonnull ((2, 4));
365: # else
366: # define getdirentries getdirentries64
367: # endif
368: # endif
369:
370: # ifdef __USE_LARGEFILE64
371: extern __ssize_t getdirentries64 (int __fd, char *__restrict __buf,
372: size_t __nbytes,
373: __off64_t *__restrict __basep)
374: __THROW __nonnull ((2, 4));
375: # endif
376: #endif
377:
378: #ifdef __USE_GNU
379:
380: # ifndef __USE_FILE_OFFSET64
381: extern int versionsort (__const struct dirent **__e1,
382: __const struct dirent **__e2)
383: __THROW __attribute_pure__ __nonnull ((1, 2));
384: # else
385: # ifdef __REDIRECT
386: extern int __REDIRECT_NTH (versionsort,
387: (__const struct dirent **__e1,
388: __const struct dirent **__e2),
389: versionsort64)
390: __attribute_pure__ __nonnull ((1, 2));
391: # else
392: # define versionsort versionsort64
393: # endif
394: # endif
395:
396: # ifdef __USE_LARGEFILE64
397: extern int versionsort64 (__const struct dirent64 **__e1,
398: __const struct dirent64 **__e2)
399: __THROW __attribute_pure__ __nonnull ((1, 2));
400: # endif
401: #endif
402:
403: __END_DECLS
404:
405: #endif
406:
© Andrew Scott 2006 -
2024,
All Rights Reserved