d: Merge upstream dmd, druntime 4c18eed967, phobos d945686a4.
[official-gcc.git] / libphobos / libdruntime / core / sys / posix / sys / stat.d
blobb89478fe7d7515b745232bc5e82f9346d22cc22e
1 /**
2 * D header file for POSIX.
4 * Copyright: Copyright Sean Kelly 2005 - 2009.
5 * License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6 * Authors: Sean Kelly, Alex Rønne Petersen
7 * Standards: The Open Group Base Specifications Issue 6, IEEE Std 1003.1, 2004 Edition
8 */
10 /* Copyright Sean Kelly 2005 - 2009.
11 * Distributed under the Boost Software License, Version 1.0.
12 * (See accompanying file LICENSE or copy at
13 * http://www.boost.org/LICENSE_1_0.txt)
15 module core.sys.posix.sys.stat;
17 import core.sys.posix.config;
18 import core.stdc.stdint;
19 import core.sys.posix.time; // for timespec
20 public import core.sys.posix.sys.types; // for off_t, mode_t
22 version (OSX)
23 version = Darwin;
24 else version (iOS)
25 version = Darwin;
26 else version (TVOS)
27 version = Darwin;
28 else version (WatchOS)
29 version = Darwin;
31 version (RISCV32) version = RISCV_Any;
32 version (RISCV64) version = RISCV_Any;
33 version (SPARC) version = SPARC_Any;
34 version (SPARC64) version = SPARC_Any;
36 version (Posix):
37 extern (C) nothrow @nogc:
40 // Required
43 struct stat
45 dev_t st_dev;
46 ino_t st_ino;
47 mode_t st_mode;
48 nlink_t st_nlink;
49 uid_t st_uid;
50 gid_t st_gid;
51 off_t st_size;
52 time_t st_atime;
53 time_t st_mtime;
54 time_t st_ctime;
57 S_ISUID
58 S_ISGID
59 S_ISVTX
61 S_TYPEISMQ(buf)
62 S_TYPEISSEM(buf)
63 S_TYPEISSHM(buf)
66 version (linux)
68 version (X86)
70 struct stat_t
72 dev_t st_dev;
73 ushort __pad1;
74 static if (!__USE_FILE_OFFSET64)
76 ino_t st_ino;
78 else
80 uint __st_ino;
82 mode_t st_mode;
83 nlink_t st_nlink;
84 uid_t st_uid;
85 gid_t st_gid;
86 dev_t st_rdev;
87 ushort __pad2;
88 off_t st_size;
89 blksize_t st_blksize;
90 blkcnt_t st_blocks;
91 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
93 timespec st_atim;
94 timespec st_mtim;
95 timespec st_ctim;
96 extern(D) @safe @property inout pure nothrow
98 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
99 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
100 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
103 else
105 time_t st_atime;
106 ulong_t st_atimensec;
107 time_t st_mtime;
108 ulong_t st_mtimensec;
109 time_t st_ctime;
110 ulong_t st_ctimensec;
112 static if (__USE_FILE_OFFSET64)
114 ino_t st_ino;
116 else
118 c_ulong __unused4;
119 c_ulong __unused5;
123 else version (X86_64)
125 struct stat_t
127 dev_t st_dev;
128 ino_t st_ino;
129 nlink_t st_nlink;
130 mode_t st_mode;
131 uid_t st_uid;
132 gid_t st_gid;
133 uint __pad0;
134 dev_t st_rdev;
135 off_t st_size;
136 blksize_t st_blksize;
137 blkcnt_t st_blocks;
138 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
140 timespec st_atim;
141 timespec st_mtim;
142 timespec st_ctim;
143 extern(D) @safe @property inout pure nothrow
145 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
146 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
147 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
150 else
152 time_t st_atime;
153 ulong_t st_atimensec;
154 time_t st_mtime;
155 ulong_t st_mtimensec;
156 time_t st_ctime;
157 ulong_t st_ctimensec;
159 slong_t[3] __unused;
162 else version (HPPA)
164 private
166 alias __dev_t = ulong;
167 alias __ino_t = c_ulong;
168 alias __ino64_t = ulong;
169 alias __mode_t = uint;
170 alias __nlink_t = size_t;
171 alias __uid_t = uint;
172 alias __gid_t = uint;
173 alias __off_t = c_long;
174 alias __off64_t = long;
175 alias __blksize_t = c_long;
176 alias __blkcnt_t = c_long;
177 alias __blkcnt64_t = long;
178 alias __timespec = timespec;
179 alias __time_t = time_t;
181 struct stat_t
183 __dev_t st_dev;
184 ushort __pad1;
186 static if (!__USE_FILE_OFFSET64)
188 __ino_t st_ino;
190 else
192 __ino_t __st_ino;
194 __mode_t st_mode;
195 __nlink_t st_nlink;
196 __uid_t st_uid;
197 __gid_t st_gid;
198 __dev_t st_rdev;
199 ushort __pad2;
201 static if (!__USE_FILE_OFFSET64)
203 __off_t st_size;
205 else
207 __off64_t st_size;
209 __blksize_t st_blksize;
211 static if (!__USE_FILE_OFFSET64)
213 __blkcnt_t st_blocks;
215 else
217 __blkcnt64_t st_blocks;
220 static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
222 __timespec st_atim;
223 __timespec st_mtim;
224 __timespec st_ctim;
225 extern(D) @safe @property inout pure nothrow
227 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
228 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
229 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
232 else
234 __time_t st_atime;
235 c_ulong st_atimensec;
236 __time_t st_mtime;
237 c_ulong st_mtimensec;
238 __time_t st_ctime;
239 c_ulong st_ctimensec;
242 static if (!__USE_FILE_OFFSET64)
244 c_ulong __unused4;
245 c_ulong __unused5;
247 else
249 __ino64_t st_ino;
252 static if (__USE_FILE_OFFSET64)
253 static assert(stat_t.sizeof == 104);
254 else
255 static assert(stat_t.sizeof == 88);
257 else version (MIPS_O32)
259 struct stat_t
261 c_ulong st_dev;
262 c_long[3] st_pad1;
263 ino_t st_ino;
264 mode_t st_mode;
265 nlink_t st_nlink;
266 uid_t st_uid;
267 gid_t st_gid;
268 c_ulong st_rdev;
269 static if (!__USE_FILE_OFFSET64)
271 c_long[2] st_pad2;
272 off_t st_size;
273 c_long st_pad3;
275 else
277 c_long[3] st_pad2;
278 off_t st_size;
280 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
282 timespec st_atim;
283 timespec st_mtim;
284 timespec st_ctim;
285 extern(D) @safe @property inout pure nothrow
287 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
288 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
289 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
292 else
294 time_t st_atime;
295 c_ulong st_atimensec;
296 time_t st_mtime;
297 c_ulong st_mtimensec;
298 time_t st_ctime;
299 c_ulong st_ctimensec;
301 blksize_t st_blksize;
302 static if (!__USE_FILE_OFFSET64)
304 blkcnt_t st_blocks;
306 else
308 c_long st_pad4;
309 blkcnt_t st_blocks;
311 c_long[14] st_pad5;
313 static if (!__USE_FILE_OFFSET64)
314 static assert(stat_t.sizeof == 144);
315 else
316 static assert(stat_t.sizeof == 160);
318 else version (MIPS64)
320 struct stat_t
322 dev_t st_dev;
323 int[3] st_pad1;
324 ino_t st_ino;
325 mode_t st_mode;
326 nlink_t st_nlink;
327 uid_t st_uid;
328 gid_t st_gid;
329 dev_t st_rdev;
330 static if (!__USE_FILE_OFFSET64)
332 uint[2] st_pad2;
333 off_t st_size;
334 int st_pad3;
336 else
338 uint[3] st_pad2;
339 off_t st_size;
341 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
343 timespec st_atim;
344 timespec st_mtim;
345 timespec st_ctim;
346 extern(D) @safe @property inout pure nothrow
348 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
349 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
350 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
353 else
355 time_t st_atime;
356 c_ulong st_atimensec;
357 time_t st_mtime;
358 c_ulong st_mtimensec;
359 time_t st_ctime;
360 c_ulong st_ctimensec;
362 blksize_t st_blksize;
363 uint st_pad4;
364 blkcnt_t st_blocks;
365 int[14] st_pad5;
367 version (MIPS_N32)
369 static if (!__USE_FILE_OFFSET64)
370 static assert(stat_t.sizeof == 160);
371 else
372 static assert(stat_t.sizeof == 176);
374 else version (MIPS_O64)
376 static if (!__USE_FILE_OFFSET64)
377 static assert(stat_t.sizeof == 160);
378 else
379 static assert(stat_t.sizeof == 176);
381 else
383 static assert(stat_t.sizeof == 216);
386 else version (PPC)
388 struct stat_t
390 dev_t st_dev;
391 static if (!__USE_FILE_OFFSET64)
393 ushort __pad1;
394 ino_t st_ino;
396 else
397 ino_t st_ino;
398 mode_t st_mode;
399 nlink_t st_nlink;
400 uid_t st_uid;
401 gid_t st_gid;
402 dev_t st_rdev;
403 ushort __pad2;
404 off_t st_size;
405 blksize_t st_blksize;
406 blkcnt_t st_blocks;
407 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
409 timespec st_atim;
410 timespec st_mtim;
411 timespec st_ctim;
412 extern(D) @safe @property inout pure nothrow
414 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
415 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
416 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
419 else
421 time_t st_atime;
422 c_ulong st_atimensec;
423 time_t st_mtime;
424 c_ulong st_mtimensec;
425 time_t st_ctime;
426 c_ulong st_ctimensec;
428 c_ulong __unused4;
429 c_ulong __unused5;
431 static if (__USE_FILE_OFFSET64)
432 static assert(stat_t.sizeof == 104);
433 else
434 static assert(stat_t.sizeof == 88);
436 else version (PPC64)
438 struct stat_t
440 dev_t st_dev;
441 ino_t st_ino;
442 nlink_t st_nlink;
443 mode_t st_mode;
444 uid_t st_uid;
445 gid_t st_gid;
446 int __pad2;
447 dev_t st_rdev;
448 off_t st_size;
449 blksize_t st_blksize;
450 blkcnt_t st_blocks;
451 static if (_DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
453 timespec st_atim;
454 timespec st_mtim;
455 timespec st_ctim;
456 extern(D) @safe @property inout pure nothrow
458 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
459 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
460 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
463 else
465 time_t st_atime;
466 c_ulong st_atimensec;
467 time_t st_mtime;
468 c_ulong st_mtimensec;
469 time_t st_ctime;
470 c_ulong st_ctimensec;
472 c_ulong __unused4;
473 c_ulong __unused5;
474 c_ulong __unused6;
476 static assert(stat_t.sizeof == 144);
478 else version (RISCV_Any)
480 private
482 alias __dev_t = ulong;
483 alias __ino_t = c_ulong;
484 alias __ino64_t = ulong;
485 alias __mode_t = uint;
486 alias __nlink_t = uint;
487 alias __uid_t = uint;
488 alias __gid_t = uint;
489 alias __off_t = c_long;
490 alias __off64_t = long;
491 alias __blksize_t = int;
492 alias __blkcnt_t = c_long;
493 alias __blkcnt64_t = long;
494 alias __timespec = timespec;
495 alias __time_t = time_t;
497 struct stat_t
499 __dev_t st_dev;
501 static if (__USE_FILE_OFFSET64)
503 __ino64_t st_ino;
505 else
507 __ino_t st_ino;
509 __mode_t st_mode;
510 __nlink_t st_nlink;
511 __uid_t st_uid;
512 __gid_t st_gid;
513 __dev_t st_rdev;
514 __dev_t __pad1;
516 static if (__USE_FILE_OFFSET64)
518 __off64_t st_size;
520 else
522 __off_t st_size;
524 __blksize_t st_blksize;
525 int __pad2;
527 static if (__USE_FILE_OFFSET64)
529 __blkcnt64_t st_blocks;
531 else
533 __blkcnt_t st_blocks;
536 static if (_DEFAULT_SOURCE)
538 __timespec st_atim;
539 __timespec st_mtim;
540 __timespec st_ctim;
541 extern(D) @safe @property inout pure nothrow
543 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
544 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
545 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
548 else
550 __time_t st_atime;
551 c_ulong st_atimensec;
552 __time_t st_mtime;
553 c_ulong st_mtimensec;
554 __time_t st_ctime;
555 c_ulong st_ctimensec;
557 int[2] __unused;
560 else version (ARM)
562 private
564 alias __dev_t = ulong;
565 alias __ino_t = c_ulong;
566 alias __ino64_t = ulong;
567 alias __mode_t = uint;
568 alias __nlink_t = size_t;
569 alias __uid_t = uint;
570 alias __gid_t = uint;
571 alias __off_t = c_long;
572 alias __off64_t = long;
573 alias __blksize_t = c_long;
574 alias __blkcnt_t = c_long;
575 alias __blkcnt64_t = long;
576 alias __timespec = timespec;
577 alias __time_t = time_t;
579 struct stat_t
581 __dev_t st_dev;
582 ushort __pad1;
584 static if (!__USE_FILE_OFFSET64)
586 __ino_t st_ino;
588 else
590 __ino_t __st_ino;
592 __mode_t st_mode;
593 __nlink_t st_nlink;
594 __uid_t st_uid;
595 __gid_t st_gid;
596 __dev_t st_rdev;
597 ushort __pad2;
599 static if (!__USE_FILE_OFFSET64)
601 __off_t st_size;
603 else
605 __off64_t st_size;
607 __blksize_t st_blksize;
609 static if (!__USE_FILE_OFFSET64)
611 __blkcnt_t st_blocks;
613 else
615 __blkcnt64_t st_blocks;
618 static if ( _DEFAULT_SOURCE || _XOPEN_SOURCE >= 700)
620 __timespec st_atim;
621 __timespec st_mtim;
622 __timespec st_ctim;
623 extern(D) @safe @property inout pure nothrow
625 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
626 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
627 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
630 else
632 __time_t st_atime;
633 c_ulong st_atimensec;
634 __time_t st_mtime;
635 c_ulong st_mtimensec;
636 __time_t st_ctime;
637 c_ulong st_ctimensec;
640 static if (!__USE_FILE_OFFSET64)
642 c_ulong __unused4;
643 c_ulong __unused5;
645 else
647 __ino64_t st_ino;
650 static if (__USE_FILE_OFFSET64)
651 static assert(stat_t.sizeof == 104);
652 else
653 static assert(stat_t.sizeof == 88);
655 else version (AArch64)
657 private
659 alias __dev_t = ulong;
660 alias __ino_t = c_ulong;
661 alias __ino64_t = ulong;
662 alias __mode_t = uint;
663 alias __nlink_t = uint;
664 alias __uid_t = uint;
665 alias __gid_t = uint;
666 alias __off_t = c_long;
667 alias __off64_t = long;
668 alias __blksize_t = int;
669 alias __blkcnt_t = c_long;
670 alias __blkcnt64_t = long;
671 alias __timespec = timespec;
672 alias __time_t = time_t;
674 struct stat_t
676 __dev_t st_dev;
678 static if (!__USE_FILE_OFFSET64)
680 __ino_t st_ino;
682 else
684 __ino64_t st_ino;
686 __mode_t st_mode;
687 __nlink_t st_nlink;
688 __uid_t st_uid;
689 __gid_t st_gid;
690 __dev_t st_rdev;
691 __dev_t __pad1;
693 static if (!__USE_FILE_OFFSET64)
695 __off_t st_size;
697 else
699 __off64_t st_size;
701 __blksize_t st_blksize;
702 int __pad2;
704 static if (!__USE_FILE_OFFSET64)
706 __blkcnt_t st_blocks;
708 else
710 __blkcnt64_t st_blocks;
713 static if (_DEFAULT_SOURCE)
715 __timespec st_atim;
716 __timespec st_mtim;
717 __timespec st_ctim;
718 extern(D) @safe @property inout pure nothrow
720 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
721 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
722 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
725 else
727 __time_t st_atime;
728 c_ulong st_atimensec;
729 __time_t st_mtime;
730 c_ulong st_mtimensec;
731 __time_t st_ctime;
732 c_ulong st_ctimensec;
734 int[2] __unused;
736 version (D_LP64)
737 static assert(stat_t.sizeof == 128);
738 else
739 static assert(stat_t.sizeof == 104);
741 else version (SPARC_Any)
743 private
745 alias __dev_t = ulong;
746 alias __ino_t = c_ulong;
747 alias __ino64_t = ulong;
748 alias __mode_t = uint;
749 alias __nlink_t = uint;
750 alias __uid_t = uint;
751 alias __gid_t = uint;
752 alias __off_t = c_long;
753 alias __off64_t = long;
754 alias __blksize_t = c_long;
755 alias __blkcnt_t = c_long;
756 alias __blkcnt64_t = long;
757 alias __timespec = timespec;
758 alias __time_t = time_t;
760 struct stat_t
762 __dev_t st_dev;
763 static if (__WORDSIZE == 64 || !__USE_FILE_OFFSET64)
765 ushort __pad1;
766 __ino_t st_ino;
768 else
770 __ino64_t st_ino;
772 __mode_t st_mode;
773 __nlink_t st_nlink;
774 __uid_t st_uid;
775 __gid_t st_gid;
776 __dev_t st_rdev;
777 ushort __pad2;
779 static if (!__USE_FILE_OFFSET64)
781 __off_t st_size;
783 else
785 __off64_t st_size;
787 __blksize_t st_blksize;
789 static if (!__USE_FILE_OFFSET64)
791 __blkcnt_t st_blocks;
793 else
795 __blkcnt64_t st_blocks;
798 static if (_XOPEN_SOURCE >= 700)
800 __timespec st_atim;
801 __timespec st_mtim;
802 __timespec st_ctim;
803 extern(D) @safe @property inout pure nothrow
805 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
806 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
807 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
810 else
812 __time_t st_atime;
813 c_ulong st_atimensec;
814 __time_t st_mtime;
815 c_ulong st_mtimensec;
816 __time_t st_ctime;
817 c_ulong st_ctimensec;
820 c_ulong __unused4;
821 c_ulong __unused5;
823 static if (__USE_LARGEFILE64) alias stat_t stat64_t;
825 static if (__WORDSIZE == 64)
826 static assert(stat_t.sizeof == 144);
827 else static if (__USE_FILE_OFFSET64)
828 static assert(stat_t.sizeof == 104);
829 else
830 static assert(stat_t.sizeof == 88);
833 else version (S390)
835 private
837 alias __dev_t = ulong;
838 alias __ino_t = c_ulong;
839 alias __ino64_t = ulong;
840 alias __mode_t = uint;
841 alias __nlink_t = uint;
842 alias __uid_t = uint;
843 alias __gid_t = uint;
844 alias __off_t = c_long;
845 alias __off64_t = long;
846 alias __blksize_t = c_long;
847 alias __blkcnt_t = c_long;
848 alias __blkcnt64_t = long;
849 alias __timespec = timespec;
850 alias __time_t = time_t;
852 struct stat_t
854 __dev_t st_dev;
855 uint __pad1;
856 static if (!__USE_FILE_OFFSET64)
857 __ino_t st_ino;
858 else
859 __ino_t __st_ino;
860 __mode_t st_mode;
861 __nlink_t st_nlink;
862 __uid_t st_uid;
863 __gid_t st_gid;
864 __dev_t st_rdev;
865 uint __pad2;
866 static if (!__USE_FILE_OFFSET64)
867 __off_t st_size;
868 else
869 __off64_t st_size;
870 __blksize_t st_blksize;
871 static if (!__USE_FILE_OFFSET64)
872 __blkcnt_t st_blocks;
873 else
874 __blkcnt64_t st_blocks;
875 static if (_XOPEN_SOURCE >= 700)
877 __timespec st_atim;
878 __timespec st_mtim;
879 __timespec st_ctim;
880 extern(D) @safe @property inout pure nothrow
882 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
883 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
884 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
887 else
889 __time_t st_atime;
890 c_ulong st_atimensec;
891 __time_t st_mtime;
892 c_ulong st_mtimensec;
893 __time_t st_ctime;
894 c_ulong st_ctimensec;
896 static if (!__USE_FILE_OFFSET64)
898 c_ulong __glibc_reserved4;
899 c_ulong __glibc_reserved5;
901 else
902 __ino64_t st_ino;
904 static if (__USE_FILE_OFFSET64)
905 static assert(stat_t.sizeof == 104);
906 else
907 static assert(stat_t.sizeof == 88);
909 else version (SystemZ)
911 private
913 alias __dev_t = ulong;
914 alias __ino_t = c_ulong;
915 alias __ino64_t = ulong;
916 alias __mode_t = uint;
917 alias __nlink_t = ulong;
918 alias __uid_t = uint;
919 alias __gid_t = uint;
920 alias __off_t = c_long;
921 alias __off64_t = long;
922 alias __blksize_t = c_long;
923 alias __blkcnt_t = c_long;
924 alias __blkcnt64_t = long;
925 alias __timespec = timespec;
926 alias __time_t = time_t;
928 struct stat_t
930 __dev_t st_dev;
931 __ino_t st_ino;
932 __nlink_t st_nlink;
933 __mode_t st_mode;
934 __uid_t st_uid;
935 __gid_t st_gid;
936 int __glibc_reserved0;
937 __dev_t st_rdev;
938 __off_t st_size;
939 static if (_XOPEN_SOURCE >= 700)
941 __timespec st_atim;
942 __timespec st_mtim;
943 __timespec st_ctim;
944 extern(D) @safe @property inout pure nothrow
946 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
947 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
948 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
951 else
953 __time_t st_atime;
954 c_ulong st_atimensec;
955 __time_t st_mtime;
956 c_ulong st_mtimensec;
957 __time_t st_ctime;
958 c_ulong st_ctimensec;
960 __blksize_t st_blksize;
961 __blkcnt_t st_blocks;
962 c_long[3] __glibc_reserved;
964 static if (_XOPEN_SOURCE >= 700)
965 static assert(stat_t.sizeof == 144);
966 else
967 static assert(stat_t.sizeof == 144);
969 else version (LoongArch64)
971 private
973 alias __dev_t = ulong;
974 alias __ino_t = c_ulong;
975 alias __ino64_t = ulong;
976 alias __mode_t = uint;
977 alias __nlink_t = uint;
978 alias __uid_t = uint;
979 alias __gid_t = uint;
980 alias __off_t = c_long;
981 alias __off64_t = long;
982 alias __blksize_t = int;
983 alias __blkcnt_t = c_long;
984 alias __blkcnt64_t = long;
985 alias __timespec = timespec;
986 alias __time_t = time_t;
988 struct stat_t
990 __dev_t st_dev;
991 __ino_t st_ino;
992 __mode_t st_mode;
993 __nlink_t st_nlink;
994 __uid_t st_uid;
995 __gid_t st_gid;
996 __dev_t st_rdev;
997 __dev_t __pad1;
998 // la64 always uses 64-bit file offsets
999 __off64_t st_size;
1000 __blksize_t st_blksize;
1001 int __pad2;
1002 // la64 always uses 64-bit block counts
1003 __blkcnt64_t st_blocks;
1004 static if (_XOPEN_SOURCE >= 700)
1006 __timespec st_atim;
1007 __timespec st_mtim;
1008 __timespec st_ctim;
1009 extern(D) @safe @property inout pure nothrow
1011 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
1012 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
1013 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
1016 else
1018 __time_t st_atime;
1019 c_ulong st_atimensec;
1020 __time_t st_mtime;
1021 c_ulong st_mtimensec;
1022 __time_t st_ctime;
1023 c_ulong st_ctimensec;
1025 int[2] __glibc_reserved;
1027 static assert(stat_t.sizeof == 128);
1029 else
1030 static assert(0, "unimplemented");
1032 enum S_ISUID = 0x800; // octal 04000
1033 enum S_ISGID = 0x400; // octal 02000
1034 enum S_ISVTX = 0x200; // octal 01000
1036 static if ( true /*__USE_POSIX199309*/ )
1038 extern bool S_TYPEISMQ( stat_t* buf ) { return false; }
1039 extern bool S_TYPEISSEM( stat_t* buf ) { return false; }
1040 extern bool S_TYPEISSHM( stat_t* buf ) { return false; }
1043 enum UTIME_NOW = 0x3fffffff;
1044 enum UTIME_OMIT = 0x3ffffffe;
1046 else version (Darwin)
1048 // _DARWIN_FEATURE_64_BIT_INODE stat is default for Mac OSX >10.5 and is
1049 // only meaningful type for other OS X/Darwin variants (e.g. iOS).
1050 // man stat(2) gives details.
1051 struct stat_t
1053 dev_t st_dev;
1054 mode_t st_mode;
1055 nlink_t st_nlink;
1056 ino_t st_ino;
1057 uid_t st_uid;
1058 gid_t st_gid;
1059 dev_t st_rdev;
1060 union
1062 struct
1064 timespec st_atimespec;
1065 timespec st_mtimespec;
1066 timespec st_ctimespec;
1067 timespec st_birthtimespec;
1069 struct
1071 time_t st_atime;
1072 c_long st_atimensec;
1073 time_t st_mtime;
1074 c_long st_mtimensec;
1075 time_t st_ctime;
1076 c_long st_ctimensec;
1077 time_t st_birthtime;
1078 c_long st_birthtimensec;
1081 off_t st_size;
1082 blkcnt_t st_blocks;
1083 blksize_t st_blksize;
1084 uint st_flags;
1085 uint st_gen;
1086 int st_lspare;
1087 long[2] st_qspare;
1090 enum S_ISUID = 0x800; // octal 04000
1091 enum S_ISGID = 0x400; // octal 02000
1092 enum S_ISVTX = 0x200; // octal 01000
1094 else version (FreeBSD)
1096 import core.sys.freebsd.config;
1098 // https://github.com/freebsd/freebsd/blob/master/sys/sys/stat.h
1099 static if (__FreeBSD_version >= INO64_FIRST)
1101 struct stat_t
1103 dev_t st_dev;
1104 ino_t st_ino;
1105 nlink_t st_nlink;
1106 mode_t st_mode;
1107 short st_padding0;
1108 uid_t st_uid;
1109 gid_t st_gid;
1110 int st_padding1;
1111 dev_t st_rdev;
1113 version (X86) int st_atim_ext;
1114 timespec st_atim;
1116 version (X86) int st_mtim_ext;
1117 timespec st_mtim;
1119 version (X86) int st_ctim_ext;
1120 timespec st_ctim;
1122 version (X86) int st_btim_ext;
1123 timespec st_birthtim;
1125 off_t st_size;
1126 blkcnt_t st_blocks;
1127 blksize_t st_blksize;
1128 fflags_t st_flags;
1129 ulong st_gen;
1130 ulong[10] st_spare;
1132 extern(D) @safe @property inout pure nothrow
1134 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
1135 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
1136 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
1137 ref inout(time_t) st_birthtime() return { return st_birthtim.tv_sec; }
1141 else
1143 struct stat_t
1145 uint st_dev;
1146 uint st_ino;
1147 mode_t st_mode;
1148 ushort st_nlink;
1149 uid_t st_uid;
1150 gid_t st_gid;
1151 uint st_rdev;
1152 timespec st_atim;
1153 timespec st_mtim;
1154 timespec st_ctim;
1155 off_t st_size;
1156 blkcnt_t st_blocks;
1157 blksize_t st_blksize;
1158 fflags_t st_flags;
1159 uint st_gen;
1160 int st_lspare;
1161 timespec st_birthtim;
1162 ubyte[16 - timespec.sizeof] padding;
1164 extern(D) @safe @property inout pure nothrow
1166 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
1167 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
1168 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
1169 ref inout(time_t) st_birthtime() return { return st_birthtim.tv_sec; }
1174 enum S_ISUID = 0x800; // octal 0004000
1175 enum S_ISGID = 0x400; // octal 0002000
1176 enum S_ISVTX = 0x200; // octal 0001000
1178 enum UTIME_NOW = -1;
1179 enum UTIME_OMIT = -2;
1181 else version (NetBSD)
1183 struct stat_t
1185 dev_t st_dev; /* inode's device */
1186 mode_t st_mode; /* inode protection mode */
1187 ino_t st_ino; /* inode's number */
1188 nlink_t st_nlink; /* number of hard links */
1189 uid_t st_uid; /* user ID of the file's owner */
1190 gid_t st_gid; /* group ID of the file's group */
1191 dev_t st_rdev; /* device type */
1192 time_t st_atime; /* time of last access */
1193 long st_atimensec; /* nsec of last access */
1194 time_t st_mtime; /* time of last data modification */
1195 long st_mtimensec; /* nsec of last data modification */
1196 time_t st_ctime; /* time of last file status change */
1197 long st_ctimensec; /* nsec of last file status change */
1198 time_t st_birthtime; /* time of creation */
1199 long st_birthtimensec; /* nsec of time of creation */
1200 off_t st_size; /* file size, in bytes */
1201 blkcnt_t st_blocks; /* blocks allocated for file */
1202 blksize_t st_blksize; /* optimal blocksize for I/O */
1203 uint32_t st_flags; /* user defined flags for file */
1204 uint32_t st_gen; /* file generation number */
1205 uint32_t[2] st_spare;
1208 enum S_ISUID = 0x800; // octal 0004000
1209 enum S_ISGID = 0x400; // octal 0002000
1210 enum S_ISVTX = 0x200; // octal 0001000
1212 else version (OpenBSD)
1214 import core.sys.openbsd.sys.cdefs;
1216 struct stat_t
1218 mode_t st_mode;
1219 dev_t st_dev;
1220 ino_t st_ino;
1221 nlink_t st_nlink;
1222 uid_t st_uid;
1223 gid_t st_gid;
1224 dev_t st_rdev;
1225 static if (__POSIX_VISIBLE >= 200809 || __BSD_VISIBLE)
1227 timespec st_atim;
1228 timespec st_mtim;
1229 timespec st_ctim;
1230 extern(D) @safe @property inout pure nothrow
1232 ref inout(time_t) st_atime() return { return st_atim.tv_sec; }
1233 ref inout(time_t) st_mtime() return { return st_mtim.tv_sec; }
1234 ref inout(time_t) st_ctime() return { return st_ctim.tv_sec; }
1237 else
1239 time_t st_atime;
1240 long st_atimensec;
1241 time_t st_mtime;
1242 long st_mtimensec;
1243 time_t st_ctime;
1244 long st_ctimensec;
1246 off_t st_size;
1247 blkcnt_t st_blocks;
1248 blksize_t st_blksize;
1249 uint32_t st_flags;
1250 uint32_t st_gen;
1251 static if (__POSIX_VISIBLE >= 200809 || __BSD_VISIBLE)
1253 timespec __st_birthtim;
1255 else
1257 time_t __st_birthtime;
1258 long __st_birthtimensec;
1262 enum S_ISUID = 0x800; // octal 0004000
1263 enum S_ISGID = 0x400; // octal 0002000
1264 enum S_ISVTX = 0x200; // octal 0001000
1266 else version (DragonFlyBSD)
1268 struct stat_t {
1269 ino_t st_ino; /* inode's number */
1270 nlink_t st_nlink; /* number of hard links */
1271 dev_t st_dev; /* inode's device */
1272 mode_t st_mode; /* inode protection mode */
1273 uint16_t st_padding1;
1274 uid_t st_uid; /* user ID of the file's owner */
1275 gid_t st_gid; /* group ID of the file's group */
1276 dev_t st_rdev; /* device type */
1277 time_t st_atime;
1278 c_long __st_atimensec;
1279 time_t st_mtime;
1280 c_long __st_mtimensec;
1281 time_t st_ctime;
1282 c_long __st_ctimensec;
1283 off_t st_size; /* file size, in bytes */
1284 int64_t st_blocks; /* blocks allocated for file */
1285 uint32_t st_blksize; /* optimal blocksize for I/O */
1286 uint32_t st_flags; /* user defined flags for file */
1287 uint32_t st_gen; /* file generation number */
1288 int32_t st_lspare;
1289 int64_t st_qspare1; /* was recursive change detect */
1290 int64_t st_qspare2;
1293 enum S_ISUID = 0x800; // octal 0004000
1294 enum S_ISGID = 0x400; // octal 0002000
1295 enum S_ISVTX = 0x200; // octal 0001000
1297 else version (Solaris)
1299 private enum _ST_FSTYPSZ = 16;
1301 version (D_LP64)
1303 struct stat_t
1305 dev_t st_dev;
1306 ino_t st_ino;
1307 mode_t st_mode;
1308 nlink_t st_nlink;
1309 uid_t st_uid;
1310 gid_t st_gid;
1311 dev_t st_rdev;
1312 off_t st_size;
1313 union
1315 timestruc_t st_atim;
1316 time_t st_atime;
1318 union
1320 timestruc_t st_mtim;
1321 time_t st_mtime;
1323 union
1325 timestruc_t st_ctim;
1326 time_t st_ctime;
1328 blksize_t st_blksize;
1329 blkcnt_t st_blocks;
1330 char[_ST_FSTYPSZ] st_fstype = 0;
1333 static if (__USE_LARGEFILE64) alias stat_t stat64_t;
1335 else
1337 struct stat32_t
1339 dev_t st_dev;
1340 c_long[3] st_pad1;
1341 ino_t st_ino;
1342 mode_t st_mode;
1343 nlink_t st_nlink;
1344 uid_t st_uid;
1345 gid_t st_gid;
1346 dev_t st_rdev;
1347 c_long[2] st_pad2;
1348 off_t st_size;
1349 c_long st_pad3;
1350 union
1352 timestruc_t st_atim;
1353 time_t st_atime;
1355 union
1357 timestruc_t st_mtim;
1358 time_t st_mtime;
1360 union
1362 timestruc_t st_ctim;
1363 time_t st_ctime;
1365 blksize_t st_blksize;
1366 blkcnt_t st_blocks;
1367 char[_ST_FSTYPSZ] st_fstype = 0;
1368 c_long[8] st_pad4;
1371 struct stat64_t
1373 dev_t st_dev;
1374 c_long[3] st_pad1;
1375 ino64_t st_ino;
1376 mode_t st_mode;
1377 nlink_t st_nlink;
1378 uid_t st_uid;
1379 gid_t st_gid;
1380 dev_t st_rdev;
1381 c_long[2] st_pad2;
1382 off64_t st_size;
1383 union
1385 timestruc_t st_atim;
1386 time_t st_atime;
1388 union
1390 timestruc_t st_mtim;
1391 time_t st_mtime;
1393 union
1395 timestruc_t st_ctim;
1396 time_t st_ctime;
1398 blksize_t st_blksize;
1399 blkcnt64_t st_blocks;
1400 char[_ST_FSTYPSZ] st_fstype = 0;
1401 c_long[8] st_pad4;
1404 static if (__USE_FILE_OFFSET64)
1405 alias stat64_t stat_t;
1406 else
1407 alias stat32_t stat_t;
1411 enum S_ISUID = 0x800;
1412 enum S_ISGID = 0x400;
1413 enum S_ISVTX = 0x200;
1415 else
1417 static assert(false, "Unsupported platform");
1421 S_IRWXU
1422 S_IRUSR
1423 S_IWUSR
1424 S_IXUSR
1425 S_IRWXG
1426 S_IRGRP
1427 S_IWGRP
1428 S_IXGRP
1429 S_IRWXO
1430 S_IROTH
1431 S_IWOTH
1432 S_IXOTH
1434 S_ISBLK(m)
1435 S_ISCHR(m)
1436 S_ISDIR(m)
1437 S_ISFIFO(m)
1438 S_ISREG(m)
1439 S_ISLNK(m)
1440 S_ISSOCK(m)
1443 version (CRuntime_Glibc)
1445 enum S_IRUSR = 0x100; // octal 0400
1446 enum S_IWUSR = 0x080; // octal 0200
1447 enum S_IXUSR = 0x040; // octal 0100
1448 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
1450 enum S_IRGRP = S_IRUSR >> 3;
1451 enum S_IWGRP = S_IWUSR >> 3;
1452 enum S_IXGRP = S_IXUSR >> 3;
1453 enum S_IRWXG = S_IRWXU >> 3;
1455 enum S_IROTH = S_IRGRP >> 3;
1456 enum S_IWOTH = S_IWGRP >> 3;
1457 enum S_IXOTH = S_IXGRP >> 3;
1458 enum S_IRWXO = S_IRWXG >> 3;
1460 private
1462 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1464 return ( mode & S_IFMT ) == mask;
1468 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1469 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1470 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1471 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1472 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1473 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1474 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1476 int utimensat(int dirfd, const char *pathname,
1477 ref const(timespec)[2] times, int flags);
1478 int futimens(int fd, ref const(timespec)[2] times);
1480 else version (Darwin)
1482 enum S_IRUSR = 0x100; // octal 0400
1483 enum S_IWUSR = 0x080; // octal 0200
1484 enum S_IXUSR = 0x040; // octal 0100
1485 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
1487 enum S_IRGRP = S_IRUSR >> 3;
1488 enum S_IWGRP = S_IWUSR >> 3;
1489 enum S_IXGRP = S_IXUSR >> 3;
1490 enum S_IRWXG = S_IRWXU >> 3;
1492 enum S_IROTH = S_IRGRP >> 3;
1493 enum S_IWOTH = S_IWGRP >> 3;
1494 enum S_IXOTH = S_IXGRP >> 3;
1495 enum S_IRWXO = S_IRWXG >> 3;
1497 private
1499 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1501 return ( mode & S_IFMT ) == mask;
1505 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1506 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1507 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1508 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1509 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1510 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1511 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1513 else version (FreeBSD)
1515 enum S_IRUSR = 0x100; // octal 0000400
1516 enum S_IWUSR = 0x080; // octal 0000200
1517 enum S_IXUSR = 0x040; // octal 0000100
1518 enum S_IRWXU = 0x1C0; // octal 0000700
1520 enum S_IRGRP = 0x020; // octal 0000040
1521 enum S_IWGRP = 0x010; // octal 0000020
1522 enum S_IXGRP = 0x008; // octal 0000010
1523 enum S_IRWXG = 0x038; // octal 0000070
1525 enum S_IROTH = 0x4; // 0000004
1526 enum S_IWOTH = 0x2; // 0000002
1527 enum S_IXOTH = 0x1; // 0000001
1528 enum S_IRWXO = 0x7; // 0000007
1530 private
1532 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1534 return ( mode & S_IFMT ) == mask;
1538 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1539 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1540 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1541 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1542 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1543 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1544 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1546 // Since FreeBSD 11:
1547 version (none)
1549 int utimensat(int dirfd, const char *pathname,
1550 ref const(timespec)[2] times, int flags);
1551 int futimens(int fd, ref const(timespec)[2] times);
1554 else version (NetBSD)
1556 enum S_IRUSR = 0x100; // octal 0000400
1557 enum S_IWUSR = 0x080; // octal 0000200
1558 enum S_IXUSR = 0x040; // octal 0000100
1559 enum S_IRWXU = 0x1C0; // octal 0000700
1561 enum S_IRGRP = 0x020; // octal 0000040
1562 enum S_IWGRP = 0x010; // octal 0000020
1563 enum S_IXGRP = 0x008; // octal 0000010
1564 enum S_IRWXG = 0x038; // octal 0000070
1566 enum S_IROTH = 0x4; // 0000004
1567 enum S_IWOTH = 0x2; // 0000002
1568 enum S_IXOTH = 0x1; // 0000001
1569 enum S_IRWXO = 0x7; // 0000007
1571 private
1573 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1575 return ( mode & S_IFMT ) == mask;
1579 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1580 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1581 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1582 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1583 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1584 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1585 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1587 else version (OpenBSD)
1589 enum S_IRUSR = 0x100; // octal 0000400
1590 enum S_IWUSR = 0x080; // octal 0000200
1591 enum S_IXUSR = 0x040; // octal 0000100
1592 enum S_IRWXU = 0x1C0; // octal 0000700
1594 enum S_IRGRP = 0x020; // octal 0000040
1595 enum S_IWGRP = 0x010; // octal 0000020
1596 enum S_IXGRP = 0x008; // octal 0000010
1597 enum S_IRWXG = 0x038; // octal 0000070
1599 enum S_IROTH = 0x4; // 0000004
1600 enum S_IWOTH = 0x2; // 0000002
1601 enum S_IXOTH = 0x1; // 0000001
1602 enum S_IRWXO = 0x7; // 0000007
1604 extern (D) bool S_ISBLK(mode_t mode) { return (mode & S_IFMT) == S_IFBLK; }
1605 extern (D) bool S_ISCHR(mode_t mode) { return (mode & S_IFMT) == S_IFCHR; }
1606 extern (D) bool S_ISDIR(mode_t mode) { return (mode & S_IFMT) == S_IFDIR; }
1607 extern (D) bool S_ISFIFO(mode_t mode) { return (mode & S_IFMT) == S_IFIFO; }
1608 extern (D) bool S_ISREG(mode_t mode) { return (mode & S_IFMT) == S_IFREG; }
1609 extern (D) bool S_ISLNK(mode_t mode) { return (mode & S_IFMT) == S_IFLNK; }
1610 extern (D) bool S_ISSOCK(mode_t mode) { return (mode & S_IFMT) == S_IFSOCK; }
1612 else version (DragonFlyBSD)
1614 enum S_IRUSR = 0x100; // octal 0000400
1615 enum S_IWUSR = 0x080; // octal 0000200
1616 enum S_IXUSR = 0x040; // octal 0000100
1617 enum S_IRWXU = 0x1C0; // octal 0000700
1619 enum S_IRGRP = 0x020; // octal 0000040
1620 enum S_IWGRP = 0x010; // octal 0000020
1621 enum S_IXGRP = 0x008; // octal 0000010
1622 enum S_IRWXG = 0x038; // octal 0000070
1624 enum S_IROTH = 0x4; // 0000004
1625 enum S_IWOTH = 0x2; // 0000002
1626 enum S_IXOTH = 0x1; // 0000001
1627 enum S_IRWXO = 0x7; // 0000007
1629 private
1631 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1633 return ( mode & S_IFMT ) == mask;
1637 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1638 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1639 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1640 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1641 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1642 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1643 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1645 else version (Solaris)
1647 enum S_IRUSR = 0x100;
1648 enum S_IWUSR = 0x080;
1649 enum S_IXUSR = 0x040;
1650 enum S_IRWXU = 0x1C0;
1652 enum S_IRGRP = 0x020;
1653 enum S_IWGRP = 0x010;
1654 enum S_IXGRP = 0x008;
1655 enum S_IRWXG = 0x038;
1657 enum S_IROTH = 0x4; // 0000004
1658 enum S_IWOTH = 0x2; // 0000002
1659 enum S_IXOTH = 0x1; // 0000001
1660 enum S_IRWXO = 0x7; // 0000007
1662 private
1664 extern (D) bool S_ISTYPE(mode_t mode, uint mask)
1666 return (mode & S_IFMT) == mask;
1670 extern (D) bool S_ISBLK(mode_t mode) { return S_ISTYPE(mode, S_IFBLK); }
1671 extern (D) bool S_ISCHR(mode_t mode) { return S_ISTYPE(mode, S_IFCHR); }
1672 extern (D) bool S_ISDIR(mode_t mode) { return S_ISTYPE(mode, S_IFDIR); }
1673 extern (D) bool S_ISFIFO(mode_t mode) { return S_ISTYPE(mode, S_IFIFO); }
1674 extern (D) bool S_ISREG(mode_t mode) { return S_ISTYPE(mode, S_IFREG); }
1675 extern (D) bool S_ISLNK(mode_t mode) { return S_ISTYPE(mode, S_IFLNK); }
1676 extern (D) bool S_ISSOCK(mode_t mode) { return S_ISTYPE(mode, S_IFSOCK); }
1677 extern (D) bool S_ISDOOR(mode_t mode) { return S_ISTYPE(mode, S_IFDOOR); }
1678 extern (D) bool S_ISPORT(mode_t mode) { return S_ISTYPE(mode, S_IFPORT); }
1680 else version (CRuntime_Bionic)
1682 enum S_IRUSR = 0x100; // octal 0000400
1683 enum S_IWUSR = 0x080; // octal 0000200
1684 enum S_IXUSR = 0x040; // octal 0000100
1685 enum S_IRWXU = 0x1C0; // octal 0000700
1687 enum S_IRGRP = 0x020; // octal 0000040
1688 enum S_IWGRP = 0x010; // octal 0000020
1689 enum S_IXGRP = 0x008; // octal 0000010
1690 enum S_IRWXG = 0x038; // octal 0000070
1692 enum S_IROTH = 0x4; // 0000004
1693 enum S_IWOTH = 0x2; // 0000002
1694 enum S_IXOTH = 0x1; // 0000001
1695 enum S_IRWXO = 0x7; // 0000007
1697 private
1699 extern (D) bool S_ISTYPE( uint mode, uint mask )
1701 return ( mode & S_IFMT ) == mask;
1705 extern (D) bool S_ISBLK( uint mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1706 extern (D) bool S_ISCHR( uint mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1707 extern (D) bool S_ISDIR( uint mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1708 extern (D) bool S_ISFIFO( uint mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1709 extern (D) bool S_ISREG( uint mode ) { return S_ISTYPE( mode, S_IFREG ); }
1710 extern (D) bool S_ISLNK( uint mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1711 extern (D) bool S_ISSOCK( uint mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1713 // Added since Lollipop
1714 int utimensat(int dirfd, const char *pathname,
1715 ref const(timespec)[2] times, int flags);
1717 else version (CRuntime_Musl)
1719 enum {
1720 S_IRUSR = 0x100, // octal 0400
1721 S_IWUSR = 0x080, // octal 0200
1722 S_IXUSR = 0x040, // octal 0100
1723 S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR,
1725 S_IRGRP = S_IRUSR >> 3,
1726 S_IWGRP = S_IWUSR >> 3,
1727 S_IXGRP = S_IXUSR >> 3,
1728 S_IRWXG = S_IRWXU >> 3,
1730 S_IROTH = S_IRGRP >> 3,
1731 S_IWOTH = S_IWGRP >> 3,
1732 S_IXOTH = S_IXGRP >> 3,
1733 S_IRWXO = S_IRWXG >> 3,
1736 private
1738 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1740 return ( mode & S_IFMT ) == mask;
1744 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1745 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1746 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1747 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1748 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1749 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1750 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1752 int utimensat(int dirfd, const char *pathname,
1753 ref const(timespec)[2] times, int flags);
1755 else version (CRuntime_UClibc)
1757 enum S_IRUSR = 0x100; // octal 0400
1758 enum S_IWUSR = 0x080; // octal 0200
1759 enum S_IXUSR = 0x040; // octal 0100
1760 enum S_IRWXU = S_IRUSR | S_IWUSR | S_IXUSR;
1762 enum S_IRGRP = S_IRUSR >> 3;
1763 enum S_IWGRP = S_IWUSR >> 3;
1764 enum S_IXGRP = S_IXUSR >> 3;
1765 enum S_IRWXG = S_IRWXU >> 3;
1767 enum S_IROTH = S_IRGRP >> 3;
1768 enum S_IWOTH = S_IWGRP >> 3;
1769 enum S_IXOTH = S_IXGRP >> 3;
1770 enum S_IRWXO = S_IRWXG >> 3;
1772 private
1774 extern (D) bool S_ISTYPE( mode_t mode, uint mask )
1776 return ( mode & S_IFMT ) == mask;
1780 extern (D) bool S_ISBLK( mode_t mode ) { return S_ISTYPE( mode, S_IFBLK ); }
1781 extern (D) bool S_ISCHR( mode_t mode ) { return S_ISTYPE( mode, S_IFCHR ); }
1782 extern (D) bool S_ISDIR( mode_t mode ) { return S_ISTYPE( mode, S_IFDIR ); }
1783 extern (D) bool S_ISFIFO( mode_t mode ) { return S_ISTYPE( mode, S_IFIFO ); }
1784 extern (D) bool S_ISREG( mode_t mode ) { return S_ISTYPE( mode, S_IFREG ); }
1785 extern (D) bool S_ISLNK( mode_t mode ) { return S_ISTYPE( mode, S_IFLNK ); }
1786 extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
1788 int utimensat(int dirfd, const char *pathname,
1789 ref const(timespec)[2] times, int flags);
1790 int futimens(int fd, ref const(timespec)[2] times);
1792 else
1794 static assert(false, "Unsupported platform");
1798 int chmod(const scope char*, mode_t);
1799 int fchmod(int, mode_t);
1800 int fstat(int, stat*);
1801 int lstat(const scope char*, stat*);
1802 int mkdir(const scope char*, mode_t);
1803 int mkfifo(const scope char*, mode_t);
1804 int stat(const scope char*, stat*);
1805 mode_t umask(mode_t);
1808 int chmod(const scope char*, mode_t);
1809 int fchmod(int, mode_t);
1810 //int fstat(int, stat_t*);
1811 //int lstat(const scope char*, stat_t*);
1812 int mkdir(const scope char*, mode_t);
1813 int mkfifo(const scope char*, mode_t);
1814 //int stat(const scope char*, stat_t*);
1815 mode_t umask(mode_t);
1817 version (CRuntime_Glibc)
1819 static if ( __USE_LARGEFILE64 )
1821 int fstat64(int, stat_t*) @trusted;
1822 alias fstat64 fstat;
1824 int lstat64(const scope char*, stat_t*);
1825 alias lstat64 lstat;
1827 int stat64(const scope char*, stat_t*);
1828 alias stat64 stat;
1830 else
1832 int fstat(int, stat_t*) @trusted;
1833 int lstat(const scope char*, stat_t*);
1834 int stat(const scope char*, stat_t*);
1837 else version (Solaris)
1839 version (D_LP64)
1841 int fstat(int, stat_t*) @trusted;
1842 int lstat(const scope char*, stat_t*);
1843 int stat(const scope char*, stat_t*);
1845 static if (__USE_LARGEFILE64)
1847 alias fstat fstat64;
1848 alias lstat lstat64;
1849 alias stat stat64;
1852 else
1854 static if (__USE_LARGEFILE64)
1856 int fstat64(int, stat_t*) @trusted;
1857 alias fstat64 fstat;
1859 int lstat64(const scope char*, stat_t*);
1860 alias lstat64 lstat;
1862 int stat64(const scope char*, stat_t*);
1863 alias stat64 stat;
1865 else
1867 int fstat(int, stat_t*) @trusted;
1868 int lstat(const scope char*, stat_t*);
1869 int stat(const scope char*, stat_t*);
1873 else version (Darwin)
1875 // OS X maintains backwards compatibility with older binaries using 32-bit
1876 // inode functions by appending $INODE64 to newer 64-bit inode functions.
1877 version (OSX)
1879 version (AArch64)
1881 int fstat(int, stat_t*);
1882 int lstat(const scope char*, stat_t*);
1883 int stat(const scope char*, stat_t*);
1885 else
1887 pragma(mangle, "fstat$INODE64") int fstat(int, stat_t*);
1888 pragma(mangle, "lstat$INODE64") int lstat(const scope char*, stat_t*);
1889 pragma(mangle, "stat$INODE64") int stat(const scope char*, stat_t*);
1892 else
1894 int fstat(int, stat_t*);
1895 int lstat(const scope char*, stat_t*);
1896 int stat(const scope char*, stat_t*);
1899 else version (FreeBSD)
1901 version (GNU)
1903 int fstat(int, stat_t*);
1904 int lstat(const scope char*, stat_t*);
1905 int stat(const scope char*, stat_t*);
1907 else
1909 static if (__FreeBSD_version >= INO64_FIRST)
1911 pragma(mangle, "fstat@FBSD_1.5") int fstat(int, stat_t*);
1912 pragma(mangle, "lstat@FBSD_1.5") int lstat(const scope char*, stat_t*);
1913 pragma(mangle, "stat@FBSD_1.5") int stat(const scope char*, stat_t*);
1915 else
1917 pragma(mangle, "fstat@FBSD_1.0") int fstat(int, stat_t*);
1918 pragma(mangle, "lstat@FBSD_1.0") int lstat(const scope char*, stat_t*);
1919 pragma(mangle, "stat@FBSD_1.0") int stat(const scope char*, stat_t*);
1923 else version (NetBSD)
1925 int __fstat50(int, stat_t*);
1926 int __lstat50(const scope char*, stat_t*);
1927 int __stat50(const scope char*, stat_t*);
1928 alias __fstat50 fstat;
1929 alias __lstat50 lstat;
1930 alias __stat50 stat;
1932 else version (OpenBSD)
1934 int fstat(int, stat_t*);
1935 int lstat(const scope char*, stat_t*);
1936 int stat(const scope char*, stat_t*);
1938 else version (DragonFlyBSD)
1940 int fstat(int, stat_t*);
1941 int lstat(const scope char*, stat_t*);
1942 int stat(const scope char*, stat_t*);
1944 else version (CRuntime_Bionic)
1946 int fstat(int, stat_t*) @trusted;
1947 int lstat(const scope char*, stat_t*);
1948 int stat(const scope char*, stat_t*);
1950 else version (CRuntime_Musl)
1952 pragma(mangle, muslRedirTime64Mangle!("stat", "__stat_time64"))
1953 int stat(const scope char*, stat_t*);
1954 pragma(mangle, muslRedirTime64Mangle!("fstat", "__fstat_time64"))
1955 int fstat(int, stat_t*);
1956 pragma(mangle, muslRedirTime64Mangle!("lstat", "__lstat_time64"))
1957 int lstat(const scope char*, stat_t*);
1959 alias fstat fstat64;
1960 alias lstat lstat64;
1961 alias stat stat64;
1963 else version (CRuntime_UClibc)
1965 static if ( __USE_LARGEFILE64 )
1967 int fstat64(int, stat_t*) @trusted;
1968 alias fstat64 fstat;
1970 int lstat64(const scope char*, stat_t*);
1971 alias lstat64 lstat;
1973 int stat64(const scope char*, stat_t*);
1974 alias stat64 stat;
1976 else
1978 int fstat(int, stat_t*) @trusted;
1979 int lstat(const scope char*, stat_t*);
1980 int stat(const scope char*, stat_t*);
1985 // Typed Memory Objects (TYM)
1988 S_TYPEISTMO(buf)
1992 // XOpen (XSI)
1995 S_IFMT
1996 S_IFBLK
1997 S_IFCHR
1998 S_IFIFO
1999 S_IFREG
2000 S_IFDIR
2001 S_IFLNK
2002 S_IFSOCK
2005 version (linux)
2007 enum S_IFMT = 0xF000; // octal 0170000
2008 enum S_IFBLK = 0x6000; // octal 0060000
2009 enum S_IFCHR = 0x2000; // octal 0020000
2010 enum S_IFIFO = 0x1000; // octal 0010000
2011 enum S_IFREG = 0x8000; // octal 0100000
2012 enum S_IFDIR = 0x4000; // octal 0040000
2013 enum S_IFLNK = 0xA000; // octal 0120000
2014 enum S_IFSOCK = 0xC000; // octal 0140000
2016 else version (Darwin)
2018 enum S_IFMT = 0xF000; // octal 0170000
2019 enum S_IFBLK = 0x6000; // octal 0060000
2020 enum S_IFCHR = 0x2000; // octal 0020000
2021 enum S_IFIFO = 0x1000; // octal 0010000
2022 enum S_IFREG = 0x8000; // octal 0100000
2023 enum S_IFDIR = 0x4000; // octal 0040000
2024 enum S_IFLNK = 0xA000; // octal 0120000
2025 enum S_IFSOCK = 0xC000; // octal 0140000
2027 else version (FreeBSD)
2029 enum S_IFMT = 0xF000; // octal 0170000
2030 enum S_IFBLK = 0x6000; // octal 0060000
2031 enum S_IFCHR = 0x2000; // octal 0020000
2032 enum S_IFIFO = 0x1000; // octal 0010000
2033 enum S_IFREG = 0x8000; // octal 0100000
2034 enum S_IFDIR = 0x4000; // octal 0040000
2035 enum S_IFLNK = 0xA000; // octal 0120000
2036 enum S_IFSOCK = 0xC000; // octal 0140000
2038 else version (NetBSD)
2040 enum S_IFMT = 0xF000; // octal 0170000
2041 enum S_IFBLK = 0x6000; // octal 0060000
2042 enum S_IFCHR = 0x2000; // octal 0020000
2043 enum S_IFIFO = 0x1000; // octal 0010000
2044 enum S_IFREG = 0x8000; // octal 0100000
2045 enum S_IFDIR = 0x4000; // octal 0040000
2046 enum S_IFLNK = 0xA000; // octal 0120000
2047 enum S_IFSOCK = 0xC000; // octal 0140000
2049 else version (OpenBSD)
2051 enum S_IFMT = 0xF000; // octal 0170000
2052 enum S_IFBLK = 0x6000; // octal 0060000
2053 enum S_IFCHR = 0x2000; // octal 0020000
2054 enum S_IFIFO = 0x1000; // octal 0010000
2055 enum S_IFREG = 0x8000; // octal 0100000
2056 enum S_IFDIR = 0x4000; // octal 0040000
2057 enum S_IFLNK = 0xA000; // octal 0120000
2058 enum S_IFSOCK = 0xC000; // octal 0140000
2060 else version (DragonFlyBSD)
2062 enum S_IFMT = 0xF000; // octal 0170000
2063 enum S_IFBLK = 0x6000; // octal 0060000
2064 enum S_IFCHR = 0x2000; // octal 0020000
2065 enum S_IFIFO = 0x1000; // octal 0010000
2066 enum S_IFREG = 0x8000; // octal 0100000
2067 enum S_IFDIR = 0x4000; // octal 0040000
2068 enum S_IFLNK = 0xA000; // octal 0120000
2069 enum S_IFSOCK = 0xC000; // octal 0140000
2071 else version (Solaris)
2073 enum S_IFMT = 0xF000;
2074 enum S_IFBLK = 0x6000;
2075 enum S_IFCHR = 0x2000;
2076 enum S_IFIFO = 0x1000;
2077 enum S_IFREG = 0x8000;
2078 enum S_IFDIR = 0x4000;
2079 enum S_IFLNK = 0xA000;
2080 enum S_IFSOCK = 0xC000;
2081 enum S_IFDOOR = 0xD000;
2082 enum S_IFPORT = 0xE000;
2084 else
2086 static assert(false, "Unsupported platform");
2090 int mknod(const scope char*, mode_t, dev_t);
2093 version (CRuntime_Glibc)
2095 int mknod(const scope char*, mode_t, dev_t);
2097 else version (Darwin)
2099 int mknod(const scope char*, mode_t, dev_t);
2101 else version (FreeBSD)
2103 version (GNU)
2105 int mknod(const scope char*, mode_t, dev_t);
2107 else
2109 static if (__FreeBSD_version >= INO64_FIRST)
2110 pragma(mangle, "mknod@FBSD_1.5") int mknod(const scope char*, mode_t, dev_t);
2111 else
2112 pragma(mangle, "mknod@FBSD_1.0") int mknod(const scope char*, mode_t, dev_t);
2115 else version (NetBSD)
2117 int mknod(const scope char*, mode_t, dev_t);
2119 else version (OpenBSD)
2121 int mknod(const scope char*, mode_t, dev_t);
2123 else version (DragonFlyBSD)
2125 int mknod(const scope char*, mode_t, dev_t);
2127 else version (Solaris)
2129 int mknod(const scope char*, mode_t, dev_t);
2131 else version (CRuntime_Bionic)
2133 int mknod(const scope char*, mode_t, dev_t);
2135 else version (CRuntime_Musl)
2137 int mknod(const scope char*, mode_t, dev_t);
2139 else version (CRuntime_UClibc)
2141 int mknod(const scope char*, mode_t, dev_t);
2143 else
2145 static assert(false, "Unsupported platform");