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
11 #include <stdio.h>
12 #include <io.h>
13
14 #ifndef RC_INVOKED
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 struct dirent
21 {
22 long d_ino; /* Always zero. */
23 unsigned short d_reclen; /* Always zero. */
24 unsigned short d_namlen; /* Length of name in d_name. */
25 char d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
26 };
27
28 #ifdef _WIN64
29 #define INTPTR __int64
30 #else
31 #define INTPTR long
32 #endif
33
34 /*
35 * This is an internal data structure. Good programmers will not use it
36 * except as an argument to one of the functions below.
37 * dd_stat field is now int (was short in older versions).
38 */
39 typedef struct
40 {
41 /* disk transfer area for this dir */
42 struct _finddata_t dd_dta;
43
44 /* dirent struct to return from dir (NOTE: this makes this thread
45 * safe as long as only one thread uses a particular DIR struct at
46 * a time) */
47 struct dirent dd_dir;
48
49 /* _findnext handle */
50 INTPTR dd_handle;
51
52 /*
53 * Status of search:
54 * 0 = not started yet (next entry to read is first entry)
55 * -1 = off the end
56 * positive = 0 based index of next entry
57 */
58 int dd_stat;
59
60 /* given path for dir with search pattern (struct is extended) */
61 char dd_name[1];
62 } DIR;
63
64 DIR* __cdecl opendir (const char*);
65 struct dirent* __cdecl readdir (DIR*);
66 int __cdecl closedir (DIR*);
67 void __cdecl rewinddir (DIR*);
68 long __cdecl telldir (DIR*);
69 void __cdecl seekdir (DIR*, long);
70
71
72 /* wide char versions */
73
74 struct _wdirent
75 {
76 long d_ino; /* Always zero. */
77 unsigned short d_reclen; /* Always zero. */
78 unsigned short d_namlen; /* Length of name in d_name. */
79 wchar_t d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
80 };
81
82 /*
83 * This is an internal data structure. Good programmers will not use it
84 * except as an argument to one of the functions below.
85 */
86 typedef struct
87 {
88 /* disk transfer area for this dir */
89 struct _wfinddata_t dd_dta;
90
91 /* dirent struct to return from dir (NOTE: this makes this thread
92 * safe as long as only one thread uses a particular DIR struct at
93 * a time) */
94 struct _wdirent dd_dir;
95
96 /* _findnext handle */
97 INTPTR dd_handle;
98
99 /*
100 * Status of search:
101 * 0 = not started yet (next entry to read is first entry)
102 * -1 = off the end
103 * positive = 0 based index of next entry
104 */
105 int dd_stat;
106
107 /* given path for dir with search pattern (struct is extended) */
108 wchar_t dd_name[1];
109 } _WDIR;
110
111
112
113 _WDIR* __cdecl _wopendir (const wchar_t*);
114 struct _wdirent* __cdecl _wreaddir (_WDIR*);
115 int __cdecl _wclosedir (_WDIR*);
116 void __cdecl _wrewinddir (_WDIR*);
117 long __cdecl _wtelldir (_WDIR*);
118 void __cdecl _wseekdir (_WDIR*, long);
119
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif /* Not RC_INVOKED */
126
127 #endif /* Not _DIRENT_H_ */