Mercurial > projects > ldc
comparison druntime/import/core/sys/posix/dirent.d @ 1458:e0b2d67cfe7c
Added druntime (this should be removed once it works).
author | Robert Clipsham <robert@octarineparrot.com> |
---|---|
date | Tue, 02 Jun 2009 17:43:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1456:7b218ec1044f | 1458:e0b2d67cfe7c |
---|---|
1 /** | |
2 * D header file for POSIX. | |
3 * | |
4 * Copyright: Copyright Sean Kelly 2005 - 2009. | |
5 * License: <a href="http://www.boost.org/LICENSE_1_0.txt>Boost License 1.0</a>. | |
6 * Authors: Sean Kelly | |
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition | |
8 * | |
9 * Copyright Sean Kelly 2005 - 2009. | |
10 * Distributed under the Boost Software License, Version 1.0. | |
11 * (See accompanying file LICENSE_1_0.txt or copy at | |
12 * http://www.boost.org/LICENSE_1_0.txt) | |
13 */ | |
14 module core.sys.posix.dirent; | |
15 | |
16 private import core.sys.posix.config; | |
17 public import core.sys.posix.sys.types; // for ino_t | |
18 | |
19 extern (C): | |
20 | |
21 // | |
22 // Required | |
23 // | |
24 /* | |
25 DIR | |
26 | |
27 struct dirent | |
28 { | |
29 char[] d_name; | |
30 } | |
31 | |
32 int closedir(DIR*); | |
33 DIR* opendir(in char*); | |
34 dirent* readdir(DIR*); | |
35 void rewinddir(DIR*); | |
36 */ | |
37 | |
38 version( linux ) | |
39 { | |
40 // NOTE: The following constants are non-standard Linux definitions | |
41 // for dirent.d_type. | |
42 enum | |
43 { | |
44 DT_UNKNOWN = 0, | |
45 DT_FIFO = 1, | |
46 DT_CHR = 2, | |
47 DT_DIR = 4, | |
48 DT_BLK = 6, | |
49 DT_REG = 8, | |
50 DT_LNK = 10, | |
51 DT_SOCK = 12, | |
52 DT_WHT = 14 | |
53 } | |
54 | |
55 struct dirent | |
56 { | |
57 ino_t d_ino; | |
58 off_t d_off; | |
59 ushort d_reclen; | |
60 ubyte d_type; | |
61 char[256] d_name; | |
62 } | |
63 | |
64 struct DIR | |
65 { | |
66 // Managed by OS | |
67 } | |
68 | |
69 static if( __USE_LARGEFILE64 ) | |
70 { | |
71 dirent* readdir64(DIR*); | |
72 alias readdir64 readdir; | |
73 } | |
74 else | |
75 { | |
76 dirent* readdir(DIR*); | |
77 } | |
78 } | |
79 else version( OSX ) | |
80 { | |
81 enum | |
82 { | |
83 DT_UNKNOWN = 0, | |
84 DT_FIFO = 1, | |
85 DT_CHR = 2, | |
86 DT_DIR = 4, | |
87 DT_BLK = 6, | |
88 DT_REG = 8, | |
89 DT_LNK = 10, | |
90 DT_SOCK = 12, | |
91 DT_WHT = 14 | |
92 } | |
93 | |
94 align(4) | |
95 struct dirent | |
96 { | |
97 ino_t d_ino; | |
98 ushort d_reclen; | |
99 ubyte d_type; | |
100 ubyte d_namlen; | |
101 char[256] d_name; | |
102 } | |
103 | |
104 struct DIR | |
105 { | |
106 // Managed by OS | |
107 } | |
108 | |
109 dirent* readdir(DIR*); | |
110 } | |
111 else version( freebsd ) | |
112 { | |
113 enum | |
114 { | |
115 DT_UNKNOWN = 0, | |
116 DT_FIFO = 1, | |
117 DT_CHR = 2, | |
118 DT_DIR = 4, | |
119 DT_BLK = 6, | |
120 DT_REG = 8, | |
121 DT_LNK = 10, | |
122 DT_SOCK = 12, | |
123 DT_WHT = 14 | |
124 } | |
125 | |
126 align(4) | |
127 struct dirent | |
128 { | |
129 uint d_fileno; | |
130 ushort d_reclen; | |
131 ubyte d_type; | |
132 ubyte d_namelen; | |
133 char[256] d_name; | |
134 } | |
135 | |
136 struct _telldir; | |
137 struct DIR | |
138 { | |
139 int dd_fd; | |
140 c_long dd_loc; | |
141 c_long dd_size; | |
142 char* dd_buf; | |
143 int dd_len; | |
144 c_long dd_seek; | |
145 c_long dd_rewind; | |
146 int dd_flags; | |
147 void* dd_lock; | |
148 _telldir* dd_td; | |
149 } | |
150 | |
151 dirent* readdir(DIR*); | |
152 } | |
153 else | |
154 { | |
155 dirent* readdir(DIR*); | |
156 } | |
157 | |
158 int closedir(DIR*); | |
159 DIR* opendir(in char*); | |
160 //dirent* readdir(DIR*); | |
161 void rewinddir(DIR*); | |
162 | |
163 // | |
164 // Thread-Safe Functions (TSF) | |
165 // | |
166 /* | |
167 int readdir_r(DIR*, dirent*, dirent**); | |
168 */ | |
169 | |
170 version( linux ) | |
171 { | |
172 static if( __USE_LARGEFILE64 ) | |
173 { | |
174 int readdir64_r(DIR*, dirent*, dirent**); | |
175 alias readdir64_r readdir_r; | |
176 } | |
177 else | |
178 { | |
179 int readdir_r(DIR*, dirent*, dirent**); | |
180 } | |
181 } | |
182 else version( OSX ) | |
183 { | |
184 int readdir_r(DIR*, dirent*, dirent**); | |
185 } | |
186 else version( freebsd ) | |
187 { | |
188 int readdir_r(DIR*, dirent*, dirent**); | |
189 } | |
190 | |
191 // | |
192 // XOpen (XSI) | |
193 // | |
194 /* | |
195 void seekdir(DIR*, c_long); | |
196 c_long telldir(DIR*); | |
197 */ | |
198 | |
199 version( linux ) | |
200 { | |
201 void seekdir(DIR*, c_long); | |
202 c_long telldir(DIR*); | |
203 } |