comparison druntime/import/stdc/posix/sys/stat.d @ 760:6f33b427bfd1

Seems like hg ignores .di files, so I missed a bunch of stuff. complete druntime should be there now :)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Wed, 12 Nov 2008 00:19:18 +0100
parents
children
comparison
equal deleted inserted replaced
759:d3eb054172f9 760:6f33b427bfd1
1 /**
2 * D header file for POSIX.
3 *
4 * Copyright: Public Domain
5 * License: Public Domain
6 * Authors: Sean Kelly
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
9 module stdc.posix.sys.stat;
10
11 private import stdc.posix.config;
12 private import stdc.stdint;
13 private import stdc.posix.time; // for timespec
14 public import stdc.stddef; // for size_t
15 public import stdc.posix.sys.types; // for off_t, mode_t
16
17 extern (C):
18
19 //
20 // Required
21 //
22 /*
23 struct stat
24 {
25 dev_t st_dev;
26 ino_t st_ino;
27 mode_t st_mode;
28 nlink_t st_nlink;
29 uid_t st_uid;
30 gid_t st_gid;
31 off_t st_size;
32 time_t st_atime;
33 time_t st_mtime;
34 time_t st_ctime;
35 }
36
37 S_IRWXU
38 S_IRUSR
39 S_IWUSR
40 S_IXUSR
41 S_IRWXG
42 S_IRGRP
43 S_IWGRP
44 S_IXGRP
45 S_IRWXO
46 S_IROTH
47 S_IWOTH
48 S_IXOTH
49 S_ISUID
50 S_ISGID
51 S_ISVTX
52
53 S_ISBLK(m)
54 S_ISCHR(m)
55 S_ISDIR(m)
56 S_ISFIFO(m)
57 S_ISREG(m)
58 S_ISLNK(m)
59 S_ISSOCK(m)
60
61 S_TYPEISMQ(buf)
62 S_TYPEISSEM(buf)
63 S_TYPEISSHM(buf)
64
65 int chmod(in char*, mode_t);
66 int fchmod(int, mode_t);
67 int fstat(int, stat*);
68 int lstat(in char*, stat*);
69 int mkdir(in char*, mode_t);
70 int mkfifo(in char*, mode_t);
71 int stat(in char*, stat*);
72 mode_t umask(mode_t);
73 */
74
75 version( linux )
76 {
77 static if( __USE_LARGEFILE64 )
78 {
79 private alias uint _pad_t;
80 }
81 else
82 {
83 private alias ushort _pad_t;
84 }
85
86 struct stat_t
87 {
88 dev_t st_dev;
89 _pad_t __pad1;
90 static if( __USE_FILE_OFFSET64 )
91 {
92 ino_t __st_ino;
93 }
94 else
95 {
96 ino_t st_ino;
97 }
98 mode_t st_mode;
99 nlink_t st_nlink;
100 uid_t st_uid;
101 gid_t st_gid;
102 dev_t st_rdev;
103 _pad_t __pad2;
104 off_t st_size;
105 blksize_t st_blksize;
106 blkcnt_t st_blocks;
107 static if( false /*__USE_MISC*/ ) // true if _BSD_SOURCE || _SVID_SOURCE
108 {
109 timespec st_atim;
110 timespec st_mtim;
111 timespec st_ctim;
112 alias st_atim.tv_sec st_atime;
113 alias st_mtim.tv_sec st_mtime;
114 alias st_ctim.tv_sec st_ctime;
115 }
116 else
117 {
118 time_t st_atime;
119 c_ulong st_atimensec;
120 time_t st_mtime;
121 c_ulong st_mtimensec;
122 time_t st_ctime;
123 c_ulong st_ctimensec;
124 }
125 static if( __USE_FILE_OFFSET64 )
126 {
127 ino_t st_ino;
128 }
129 else
130 {
131 c_ulong __unused4;
132 c_ulong __unused5;
133 }
134 }
135
136 const S_IRUSR = 0400;
137 const S_IWUSR = 0200;
138 const S_IXUSR = 0100;
139 const S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
140
141 const S_IRGRP = S_IRUSR >> 3;
142 const S_IWGRP = S_IWUSR >> 3;
143 const S_IXGRP = S_IXUSR >> 3;
144 const S_IRWXG = S_IRWXU >> 3;
145
146 const S_IROTH = S_IRGRP >> 3;
147 const S_IWOTH = S_IWGRP >> 3;
148 const S_IXOTH = S_IXGRP >> 3;
149 const S_IRWXO = S_IRWXG >> 3;
150
151 const S_ISUID = 04000;
152 const S_ISGID = 02000;
153 const S_ISVTX = 01000;
154
155 private
156 {
157 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
158 {
159 return ( mode & S_IFMT ) == mask;
160 }
161 }
162
163 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
164 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
165 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
166 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
167 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
168 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
169 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
170
171 static if( true /*__USE_POSIX199309*/ )
172 {
173 extern bool S_TYPEISMQ( stat_t* buf ) { return false; }
174 extern bool S_TYPEISSEM( stat_t* buf ) { return false; }
175 extern bool S_TYPEISSHM( stat_t* buf ) { return false; }
176 }
177 }
178 else version( darwin )
179 {
180 struct stat_t
181 {
182 dev_t st_dev;
183 ino_t st_ino;
184 mode_t st_mode;
185 nlink_t st_nlink;
186 uid_t st_uid;
187 gid_t st_gid;
188 dev_t st_rdev;
189 time_t st_atime;
190 c_ulong st_atimensec;
191 time_t st_mtime;
192 c_ulong st_mtimensec;
193 time_t st_ctime;
194 c_ulong st_ctimensec;
195 off_t st_size;
196 blkcnt_t st_blocks;
197 blksize_t st_blksize;
198 uint st_flags;
199 uint st_gen;
200 int st_lspare;
201 long st_qspare[2];
202 }
203
204 const S_IRUSR = 0400;
205 const S_IWUSR = 0200;
206 const S_IXUSR = 0100;
207 const S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
208
209 const S_IRGRP = S_IRUSR >> 3;
210 const S_IWGRP = S_IWUSR >> 3;
211 const S_IXGRP = S_IXUSR >> 3;
212 const S_IRWXG = S_IRWXU >> 3;
213
214 const S_IROTH = S_IRGRP >> 3;
215 const S_IWOTH = S_IWGRP >> 3;
216 const S_IXOTH = S_IXGRP >> 3;
217 const S_IRWXO = S_IRWXG >> 3;
218
219 const S_ISUID = 04000;
220 const S_ISGID = 02000;
221 const S_ISVTX = 01000;
222
223 private
224 {
225 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
226 {
227 return ( mode & S_IFMT ) == mask;
228 }
229 }
230
231 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
232 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
233 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
234 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
235 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
236 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
237 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
238 }
239 else version( freebsd )
240 {
241 struct stat_t
242 {
243 dev_t st_dev;
244 ino_t st_ino;
245 mode_t st_mode;
246 nlink_t st_nlink;
247 uid_t st_uid;
248 gid_t st_gid;
249 dev_t st_rdev;
250
251 timespec st_atimespec;
252 timespec st_mtimespec;
253 timespec st_ctimespec;
254 time_t st_atime()
255 {
256 return st_atimespec.tv_sec;
257 }
258 time_t st_mtime()
259 {
260 return st_mtimespec.tv_sec;
261 }
262 time_t st_ctime()
263 {
264 return st_ctimespec.tv_sec;
265 }
266
267 off_t st_size;
268 blkcnt_t st_blocks;
269 blksize_t st_blksize;
270 fflags_t st_flags;
271 uint st_gen;
272 int st_lspare;
273 timespec st_birthtimespec;
274
275 byte[16 - timespec.sizeof] padding;
276 }
277
278 const S_IRUSR = 0000400;
279 const S_IWUSR = 0000200;
280 const S_IXUSR = 0000100;
281 const S_IRWXU = 0000700;
282
283 const S_IRGRP = 0000040;
284 const S_IWGRP = 0000020;
285 const S_IXGRP = 0000010;
286 const S_IRWXG = 0000070;
287
288 const S_IROTH = 0000004;
289 const S_IWOTH = 0000002;
290 const S_IXOTH = 0000001;
291 const S_IRWXO = 0000007;
292
293 const S_ISUID = 0004000;
294 const S_ISGID = 0002000;
295 const S_ISVTX = 0001000;
296
297 private
298 {
299 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
300 {
301 return ( mode & S_IFMT ) == mask;
302 }
303 }
304
305 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
306 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
307 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
308 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
309 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
310 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
311 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
312 }
313
314 int chmod(in char*, mode_t);
315 int fchmod(int, mode_t);
316 //int fstat(int, stat_t*);
317 //int lstat(in char*, stat_t*);
318 int mkdir(in char*, mode_t);
319 int mkfifo(in char*, mode_t);
320 //int stat(in char*, stat_t*);
321 mode_t umask(mode_t);
322
323 version( linux )
324 {
325 static if( __USE_LARGEFILE64 )
326 {
327 int fstat64(int, stat_t*);
328 alias fstat64 fstat;
329
330 int lstat64(in char*, stat_t*);
331 alias lstat64 lstat;
332
333 int stat64(in char*, stat_t*);
334 alias stat64 stat;
335 }
336 else
337 {
338 int fstat(int, stat_t*);
339 int lstat(in char*, stat_t*);
340 int stat(in char*, stat_t*);
341 }
342 }
343 else
344 {
345 int fstat(int, stat_t*);
346 int lstat(in char*, stat_t*);
347 int stat(in char*, stat_t*);
348 }
349
350 //
351 // Typed Memory Objects (TYM)
352 //
353 /*
354 S_TYPEISTMO(buf)
355 */
356
357 //
358 // XOpen (XSI)
359 //
360 /*
361 S_IFMT
362 S_IFBLK
363 S_IFCHR
364 S_IFIFO
365 S_IFREG
366 S_IFDIR
367 S_IFLNK
368 S_IFSOCK
369
370 int mknod(in 3char*, mode_t, dev_t);
371 */
372
373 version( linux )
374 {
375 const S_IFMT = 0170000;
376 const S_IFBLK = 0060000;
377 const S_IFCHR = 0020000;
378 const S_IFIFO = 0010000;
379 const S_IFREG = 0100000;
380 const S_IFDIR = 0040000;
381 const S_IFLNK = 0120000;
382 const S_IFSOCK = 0140000;
383
384 int mknod(in char*, mode_t, dev_t);
385 }
386 else version( darwin )
387 {
388 const S_IFMT = 0170000;
389 const S_IFBLK = 0060000;
390 const S_IFCHR = 0020000;
391 const S_IFIFO = 0010000;
392 const S_IFREG = 0100000;
393 const S_IFDIR = 0040000;
394 const S_IFLNK = 0120000;
395 const S_IFSOCK = 0140000;
396
397 int mknod(in char*, mode_t, dev_t);
398 }
399 else version( freebsd )
400 {
401 const S_IFMT = 0170000;
402 const S_IFBLK = 0060000;
403 const S_IFCHR = 0020000;
404 const S_IFIFO = 0010000;
405 const S_IFREG = 0100000;
406 const S_IFDIR = 0040000;
407 const S_IFLNK = 0120000;
408 const S_IFSOCK = 0140000;
409
410 int mknod(in char*, mode_t, dev_t);
411 }