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 )
251 timespec st_atimespec;
252 timespec st_mtimespec;
253 timespec st_ctimespec;
256 return st_atimespec.tv_sec;
260 return st_mtimespec.tv_sec;
264 return st_ctimespec.tv_sec;
269 blksize_t st_blksize;
273 timespec st_birthtimespec;
275 byte[16 - timespec.sizeof] padding;
278 const S_IRUSR = 0000400;
279 const S_IWUSR = 0000200;
280 const S_IXUSR = 0000100;
281 const S_IRWXU = 0000700;
283 const S_IRGRP = 0000040;
284 const S_IWGRP = 0000020;
285 const S_IXGRP = 0000010;
286 const S_IRWXG = 0000070;
288 const S_IROTH = 0000004;
289 const S_IWOTH = 0000002;
290 const S_IXOTH = 0000001;
291 const S_IRWXO = 0000007;
293 const S_ISUID = 0004000;
294 const S_ISGID = 0002000;
295 const S_ISVTX = 0001000;
299 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
301 return ( mode & S_IFMT ) == mask;
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 ); }
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);
325 static if( __USE_LARGEFILE64 )
327 int fstat64(int, stat_t*);
330 int lstat64(in char*, stat_t*);
333 int stat64(in char*, stat_t*);
338 int fstat(int, stat_t*);
339 int lstat(in char*, stat_t*);
340 int stat(in char*, stat_t*);
345 int fstat(int, stat_t*);
346 int lstat(in char*, stat_t*);
347 int stat(in char*, stat_t*);
351 // Typed Memory Objects (TYM)
370 int mknod(in 3char*, mode_t, dev_t);
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;
384 int mknod(in char*, mode_t, dev_t);
386 else version( darwin )
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;
397 int mknod(in char*, mode_t, dev_t);
399 else version( freebsd )
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;
410 int mknod(in char*, mode_t, dev_t);