source: Daodan/MinGW/include/dirent.h@ 1163

Last change on this file since 1163 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 5.6 KB
RevLine 
[1046]1/*
2 * DIRENT.H (formerly DIRLIB.H)
3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
6 *
7 */
8#ifndef _DIRENT_H_
9#define _DIRENT_H_
10#pragma GCC system_header
11
12/* All the headers include this file. */
13#include <_mingw.h>
14
15#include <io.h>
16
17#ifndef RC_INVOKED
18
19_BEGIN_C_DECLS
20
21struct dirent
22{
23 long d_ino; /* Always zero. */
24 unsigned short d_reclen; /* Always sizeof struct dirent. */
25 unsigned short d_namlen; /* Length of name in d_name. */
26 unsigned d_type; /* File attributes */
27 char d_name[FILENAME_MAX]; /* File name. */
28};
29
30/* This opaque data type represents the private structure
31 * through which a directory stream is referenced.
32 */
33typedef struct __dirstream_t DIR;
34
35DIR* __cdecl __MINGW_NOTHROW __mingw_opendir (const char*);
36struct dirent* __cdecl __MINGW_NOTHROW __mingw_readdir (DIR*);
37int __cdecl __MINGW_NOTHROW __mingw_closedir (DIR*);
38void __cdecl __MINGW_NOTHROW __mingw_rewinddir (DIR*);
39long __cdecl __MINGW_NOTHROW __mingw_telldir (DIR*);
40void __cdecl __MINGW_NOTHROW __mingw_seekdir (DIR*, long);
41
42__CRT_ALIAS __JMPSTUB__(( FUNCTION = opendir ))
43DIR* __cdecl __MINGW_NOTHROW opendir (const char *__dirname)
44{ return __mingw_opendir (__dirname); }
45
46__CRT_ALIAS __JMPSTUB__(( FUNCTION = readdir ))
47struct dirent* __cdecl __MINGW_NOTHROW readdir (DIR *__dir)
48{ return __mingw_readdir (__dir); }
49
50__CRT_ALIAS __JMPSTUB__(( FUNCTION = closedir ))
51int __cdecl __MINGW_NOTHROW closedir (DIR *__dir)
52{ return __mingw_closedir (__dir); }
53
54__CRT_ALIAS __JMPSTUB__(( FUNCTION = rewinddir ))
55void __cdecl __MINGW_NOTHROW rewinddir (DIR *__dir)
56{ return __mingw_rewinddir (__dir); }
57
58__CRT_ALIAS __JMPSTUB__(( FUNCTION = telldir ))
59long __cdecl __MINGW_NOTHROW telldir (DIR *__dir)
60{ return __mingw_telldir (__dir); }
61
62__CRT_ALIAS __JMPSTUB__(( FUNCTION = seekdir ))
63void __cdecl __MINGW_NOTHROW seekdir (DIR *__dir, long __loc)
64{ return __mingw_seekdir (__dir, __loc); }
65
66
67/* wide char versions */
68
69struct _wdirent
70{
71 long d_ino; /* Always zero. */
72 unsigned short d_reclen; /* Always size of struct _wdirent. */
73 unsigned short d_namlen; /* Length of name in d_name. */
74 unsigned d_type; /* File attributes */
75 wchar_t d_name[FILENAME_MAX]; /* File name. */
76};
77
78/* This opaque data type represents the private structure
79 * through which a wide directory stream is referenced.
80 */
81typedef struct __wdirstream_t _WDIR;
82
83_WDIR* __cdecl __MINGW_NOTHROW __mingw__wopendir (const wchar_t*);
84struct _wdirent* __cdecl __MINGW_NOTHROW __mingw__wreaddir (_WDIR*);
85int __cdecl __MINGW_NOTHROW __mingw__wclosedir (_WDIR*);
86void __cdecl __MINGW_NOTHROW __mingw__wrewinddir (_WDIR*);
87long __cdecl __MINGW_NOTHROW __mingw__wtelldir (_WDIR*);
88void __cdecl __MINGW_NOTHROW __mingw__wseekdir (_WDIR*, long);
89
90__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wopendir ))
91_WDIR* __cdecl __MINGW_NOTHROW _wopendir (const wchar_t *__dirname)
92{ return __mingw__wopendir (__dirname); }
93
94__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wreaddir ))
95struct _wdirent* __cdecl __MINGW_NOTHROW _wreaddir (_WDIR *__dir)
96{ return __mingw__wreaddir (__dir); }
97
98__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wclosedir ))
99int __cdecl __MINGW_NOTHROW _wclosedir (_WDIR *__dir)
100{ return __mingw__wclosedir (__dir); }
101
102__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wrewinddir ))
103void __cdecl __MINGW_NOTHROW _wrewinddir (_WDIR *__dir)
104{ return __mingw__wrewinddir (__dir); }
105
106__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wtelldir ))
107long __cdecl __MINGW_NOTHROW _wtelldir (_WDIR *__dir)
108{ return __mingw__wtelldir (__dir); }
109
110__CRT_ALIAS __JMPSTUB__(( FUNCTION = _wseekdir ))
111void __cdecl __MINGW_NOTHROW _wseekdir (_WDIR *__dir, long __loc)
112{ return __mingw__wseekdir (__dir, __loc); }
113
114_END_C_DECLS
115
116#if defined(_BSD_SOURCE) || defined(_WIN32)
117/*
118 * BSD-ish systems define manifest constants for the d_type field;
119 * although probably only DT_REG and DT_DIR are useful on Win32, we
120 * try to map them as best we can from the _finddata.attrib field.
121 *
122 * The relevant Microsoft manifest values are:
123 *
124 * _A_NORMAL (0x0000) normal file: best fit for DT_REG
125 * _A_RDONLY (0x0001) read-only: no BSD d_type equivalent
126 * _A_HIDDEN (0x0002) hidden entity: no BSD equivalent
127 * _A_SYSTEM (0x0004) system entity: no BSD equivalent
128 * _A_VOLID (0x0008) volume label: no BSD equivalent
129 * _A_SUBDIR (0x0010) directory: best fit for DT_DIR
130 * _A_ARCH (0x0020) "dirty": no BSD equivalent
131 *
132 * Thus, we may immediately define:
133 */
134#define DT_REG _A_NORMAL
135#define DT_DIR _A_SUBDIR
136
137/* The remaining BSD d_type manifest values have no Win32 equivalents;
138 * we will define them artificially, and then we will ensure that our
139 * opendir()/readdir() implementation will never assign them; (we will
140 * substitute DT_UNKNOWN, but it would be unwise to simply make these
141 * equivalent to that, since an application is likely to simply check
142 * for d_type equal to any one of these defined types, and thus could
143 * mistakenly identify DT_UNKNOWN as being of the tested type):
144 */
145#define DT_BLK (((_A_SUBDIR) << 4) | DT_UNKNOWN)
146#define DT_CHR (((_A_SUBDIR) << 5) | DT_UNKNOWN)
147#define DT_FIFO (((_A_SUBDIR) << 6) | DT_UNKNOWN)
148#define DT_LNK (((_A_SUBDIR) << 7) | DT_UNKNOWN)
149#define DT_SOCK (((_A_SUBDIR) << 8) | DT_UNKNOWN)
150
151/* No file system entity can ever be simultaneously a volume label
152 * and a directory; we will exploit this to unambiguously define:
153 */
154#define DT_UNKNOWN (_A_VOLID | _A_SUBDIR)
155
156#define _DIRENT_HAVE_D_TYPE 1
157#define _DIRENT_HAVE_D_RECLEN 1
158#define _DIRENT_HAVE_D_NAMLEN 1
159
160#endif /* _BSD_SOURCE */
161#endif /* ! RC_INVOKED */
162
163#endif /* !defined _DIRENT_H_ */
Note: See TracBrowser for help on using the repository browser.