2 * D header file for POSIX.
4 * Copyright: Public Domain
5 * License: Public Domain
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
9 module stdc.posix.sys.stat;
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
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*);
77 static if( __USE_LARGEFILE64 )
79 private alias uint _pad_t;
83 private alias ushort _pad_t;
90 static if( __USE_FILE_OFFSET64 )
105 blksize_t st_blksize;
107 static if( false /*__USE_MISC*/ ) // true if _BSD_SOURCE || _SVID_SOURCE
112 alias st_atim.tv_sec st_atime;
113 alias st_mtim.tv_sec st_mtime;
114 alias st_ctim.tv_sec st_ctime;
119 c_ulong st_atimensec;
121 c_ulong st_mtimensec;
123 c_ulong st_ctimensec;
125 static if( __USE_FILE_OFFSET64 )
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;
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;
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;
151 const S_ISUID = 04000;
152 const S_ISGID = 02000;
153 const S_ISVTX = 01000;
157 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
159 return ( mode & S_IFMT ) == mask;
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 ); }
171 static if( true /*__USE_POSIX199309*/ )
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; }
178 else version( darwin )
190 c_ulong st_atimensec;
192 c_ulong st_mtimensec;
194 c_ulong st_ctimensec;
197 blksize_t st_blksize;
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;
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;
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;
219 const S_ISUID = 04000;
220 const S_ISGID = 02000;
221 const S_ISVTX = 01000;
225 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
227 return ( mode & S_IFMT ) == mask;
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 ); }
239 else version( freebsd )
258 blksize_t st_blksize;
263 c_long st_birthtimensec;
266 const S_IRUSR = 0000400;
267 const S_IWUSR = 0000200;
268 const S_IXUSR = 0000100;
269 const S_IRWXU = 0000700;
271 const S_IRGRP = 0000040;
272 const S_IWGRP = 0000020;
273 const S_IXGRP = 0000010;
274 const S_IRWXG = 0000070;
276 const S_IROTH = 0000004;
277 const S_IWOTH = 0000002;
278 const S_IXOTH = 0000001;
279 const S_IRWXO = 0000007;
281 const S_ISUID = 0004000;
282 const S_ISGID = 0002000;
283 const S_ISVTX = 0001000;
287 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
289 return ( mode & S_IFMT ) == mask;
293 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
294 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
295 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
296 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
297 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
298 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
299 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
302 int chmod(in char*, mode_t);
303 int fchmod(int, mode_t);
304 //int fstat(int, stat_t*);
305 //int lstat(in char*, stat_t*);
306 int mkdir(in char*, mode_t);
307 int mkfifo(in char*, mode_t);
308 //int stat(in char*, stat_t*);
309 mode_t umask(mode_t);
313 static if( __USE_LARGEFILE64 )
315 int fstat64(int, stat_t*);
318 int lstat64(in char*, stat_t*);
321 int stat64(in char*, stat_t*);
326 int fstat(int, stat_t*);
327 int lstat(in char*, stat_t*);
328 int stat(in char*, stat_t*);
333 int fstat(int, stat_t*);
334 int lstat(in char*, stat_t*);
335 int stat(in char*, stat_t*);
339 // Typed Memory Objects (TYM)
358 int mknod(in 3char*, mode_t, dev_t);
363 const S_IFMT = 0170000;
364 const S_IFBLK = 0060000;
365 const S_IFCHR = 0020000;
366 const S_IFIFO = 0010000;
367 const S_IFREG = 0100000;
368 const S_IFDIR = 0040000;
369 const S_IFLNK = 0120000;
370 const S_IFSOCK = 0140000;
372 int mknod(in char*, mode_t, dev_t);
374 else version( darwin )
376 const S_IFMT = 0170000;
377 const S_IFBLK = 0060000;
378 const S_IFCHR = 0020000;
379 const S_IFIFO = 0010000;
380 const S_IFREG = 0100000;
381 const S_IFDIR = 0040000;
382 const S_IFLNK = 0120000;
383 const S_IFSOCK = 0140000;
385 int mknod(in char*, mode_t, dev_t);
387 else version( freebsd )
389 const S_IFMT = 0170000;
390 const S_IFBLK = 0060000;
391 const S_IFCHR = 0020000;
392 const S_IFIFO = 0010000;
393 const S_IFREG = 0100000;
394 const S_IFDIR = 0040000;
395 const S_IFLNK = 0120000;
396 const S_IFSOCK = 0140000;
398 int mknod(in char*, mode_t, dev_t);