]>
Commit | Line | Data |
---|---|---|
194d9eb3 CV |
1 | /* Posix dirent.h for WIN32. |
2 | ||
bc837d22 | 3 | Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2010, 2012 Red Hat, Inc. |
194d9eb3 CV |
4 | |
5 | This software is a copyrighted work licensed under the terms of the | |
6 | Cygwin license. Please consult the file "CYGWIN_LICENSE" for | |
7 | details. */ | |
8 | ||
9 | /* Including this file should not require any Windows headers. */ | |
05726ddd | 10 | |
194d9eb3 CV |
11 | #ifndef _SYS_DIRENT_H |
12 | #define _SYS_DIRENT_H | |
13 | ||
14 | #include <sys/types.h> | |
36093cfb | 15 | #include <limits.h> |
194d9eb3 CV |
16 | |
17 | #define __DIRENT_VERSION 2 | |
18 | ||
19 | #pragma pack(push,4) | |
fa421c7a | 20 | #define _DIRENT_HAVE_D_TYPE |
194d9eb3 CV |
21 | struct dirent |
22 | { | |
868fb2ff | 23 | long __d_version; /* Used internally */ |
9e5f45ed | 24 | __ino64_t d_ino; |
fa421c7a CV |
25 | unsigned char d_type; |
26 | unsigned char __d_unused1[3]; | |
9e5f45ed | 27 | __uint32_t __d_internal1; |
5224a7bb | 28 | char d_name[NAME_MAX + 1]; |
194d9eb3 | 29 | }; |
194d9eb3 CV |
30 | #pragma pack(pop) |
31 | ||
5c9d7a42 CV |
32 | #define d_fileno d_ino /* BSD compatible definition */ |
33 | ||
194d9eb3 CV |
34 | #define __DIRENT_COOKIE 0xdede4242 |
35 | ||
0c7b5572 | 36 | #pragma pack(push,4) |
194d9eb3 CV |
37 | typedef struct __DIR |
38 | { | |
39 | /* This is first to set alignment in non _COMPILING_NEWLIB case. */ | |
40 | unsigned long __d_cookie; | |
41 | struct dirent *__d_dirent; | |
90e1ee2b | 42 | char *__d_dirname; /* directory name with trailing '*' */ |
c492992f | 43 | long __d_position; /* used by telldir/seekdir */ |
868fb2ff | 44 | int __d_fd; |
e817fd3c | 45 | unsigned __d_internal; |
0c7b5572 CF |
46 | void *__handle; |
47 | void *__fh; | |
48 | unsigned __flags; | |
194d9eb3 | 49 | } DIR; |
0c7b5572 | 50 | #pragma pack(pop) |
194d9eb3 CV |
51 | |
52 | DIR *opendir (const char *); | |
40570a82 | 53 | DIR *fdopendir (int); |
194d9eb3 | 54 | struct dirent *readdir (DIR *); |
d9a22764 | 55 | int readdir_r (DIR *, struct dirent *, struct dirent **); |
194d9eb3 CV |
56 | void rewinddir (DIR *); |
57 | int closedir (DIR *); | |
58 | ||
59 | int dirfd (DIR *); | |
60 | ||
61 | #ifndef _POSIX_SOURCE | |
62 | #ifndef __INSIDE_CYGWIN__ | |
c492992f CV |
63 | long telldir (DIR *); |
64 | void seekdir (DIR *, long loc); | |
194d9eb3 CV |
65 | #endif |
66 | ||
67 | int scandir (const char *__dir, | |
68 | struct dirent ***__namelist, | |
69 | int (*select) (const struct dirent *), | |
70 | int (*compar) (const struct dirent **, const struct dirent **)); | |
71 | ||
e587f14b YS |
72 | int scandirat (int __dirfd, const char *__dir, struct dirent ***__namelist, |
73 | int (*select) (const struct dirent *), | |
74 | int (*compar) (const struct dirent **, const struct dirent **)); | |
75 | ||
194d9eb3 | 76 | int alphasort (const struct dirent **__a, const struct dirent **__b); |
fa421c7a | 77 | #ifdef _DIRENT_HAVE_D_TYPE |
244f5a27 CF |
78 | /* File types for `d_type'. */ |
79 | enum | |
1cd06583 CF |
80 | { |
81 | DT_UNKNOWN = 0, | |
244f5a27 | 82 | # define DT_UNKNOWN DT_UNKNOWN |
1cd06583 | 83 | DT_FIFO = 1, |
244f5a27 | 84 | # define DT_FIFO DT_FIFO |
1cd06583 | 85 | DT_CHR = 2, |
244f5a27 | 86 | # define DT_CHR DT_CHR |
1cd06583 | 87 | DT_DIR = 4, |
244f5a27 | 88 | # define DT_DIR DT_DIR |
1cd06583 | 89 | DT_BLK = 6, |
244f5a27 | 90 | # define DT_BLK DT_BLK |
1cd06583 | 91 | DT_REG = 8, |
244f5a27 | 92 | # define DT_REG DT_REG |
1cd06583 | 93 | DT_LNK = 10, |
244f5a27 | 94 | # define DT_LNK DT_LNK |
1cd06583 | 95 | DT_SOCK = 12, |
244f5a27 | 96 | # define DT_SOCK DT_SOCK |
1cd06583 | 97 | DT_WHT = 14 |
244f5a27 | 98 | # define DT_WHT DT_WHT |
1cd06583 | 99 | }; |
244f5a27 CF |
100 | |
101 | /* Convert between stat structure types and directory types. */ | |
1cd06583 | 102 | # define IFTODT(mode) (((mode) & 0170000) >> 12) |
244f5a27 | 103 | # define DTTOIF(dirtype) ((dirtype) << 12) |
fa421c7a | 104 | #endif /* _DIRENT_HAVE_D_TYPE */ |
194d9eb3 | 105 | #endif /* _POSIX_SOURCE */ |
1cd06583 | 106 | #endif /*_SYS_DIRENT_H*/ |